VLCMediaPlayer
2015-03-14 18:12
330 查看
VLCMediaPlayer比苹果自带的播放器更强大,用法:
#import <UIKit/UIKit.h>
#import <MobileVLCKit/MobileVLCKit.h>
@interface ViewController : UIViewController {
UIView *videoView;
VLCMediaPlayer *vlcPlayer;
}
@end
#import "ViewController.h"
/* 确保选中 GNU C++ 而不是Apple的C++ */
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
videoView = [[UIView alloc] initWithFrame:CGRectMake(10, 80, 300, 300)];
videoView.backgroundColor = [UIColor blackColor];
[self.view addSubview:videoView];
// 1. 创建一个播放器
vlcPlayer = [[VLCMediaPlayer alloc] initWithOptions:nil];
// 2. 让videoView作为vlc的视频播放的内容
vlcPlayer.drawable = videoView;
UIButton *b = [UIButton buttonWithType:UIButtonTypeSystem];
b.frame = CGRectMake(100, 30, 100, 40);
[b setTitle:@"开始播放" forState:UIControlStateNormal];
[b addTarget:self action:@selector(playVlc:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:b];
}
- (void) playVlc:(UIButton *)b {
NSString *urlpath = @"http://zb.v.qq.com:1863/?progid=4035478592";
// urlpath = @"http://192.168.88.10/app/qfts/ms/friends/0101/0101.m3u8";
// urlpath = @"rtsp://192.168.88.20:1935/live/yangcam";
NSURL *url = [NSURL URLWithString:urlpath];
// 3. 创建一个播放对象
VLCMedia *item = [[VLCMedia alloc] initWithURL:url];
[vlcPlayer setMedia:item];
[vlcPlayer play];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
#import <UIKit/UIKit.h>
#import <MobileVLCKit/MobileVLCKit.h>
@interface ViewController : UIViewController {
UIView *videoView;
VLCMediaPlayer *vlcPlayer;
}
@end
#import "ViewController.h"
/* 确保选中 GNU C++ 而不是Apple的C++ */
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
videoView = [[UIView alloc] initWithFrame:CGRectMake(10, 80, 300, 300)];
videoView.backgroundColor = [UIColor blackColor];
[self.view addSubview:videoView];
// 1. 创建一个播放器
vlcPlayer = [[VLCMediaPlayer alloc] initWithOptions:nil];
// 2. 让videoView作为vlc的视频播放的内容
vlcPlayer.drawable = videoView;
UIButton *b = [UIButton buttonWithType:UIButtonTypeSystem];
b.frame = CGRectMake(100, 30, 100, 40);
[b setTitle:@"开始播放" forState:UIControlStateNormal];
[b addTarget:self action:@selector(playVlc:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:b];
}
- (void) playVlc:(UIButton *)b {
NSString *urlpath = @"http://zb.v.qq.com:1863/?progid=4035478592";
// urlpath = @"http://192.168.88.10/app/qfts/ms/friends/0101/0101.m3u8";
// urlpath = @"rtsp://192.168.88.20:1935/live/yangcam";
NSURL *url = [NSURL URLWithString:urlpath];
// 3. 创建一个播放对象
VLCMedia *item = [[VLCMedia alloc] initWithURL:url];
[vlcPlayer setMedia:item];
[vlcPlayer play];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
相关文章推荐
- [Windows] 解决 VLC Media Player 的 Crash Reporting 消息弹窗
- libvlc media player in C# (part 1)
- VLC media player——多媒体播放
- 用VLC media player com组件检查mms地址是否可以收听详解
- Uninstall VLC media player with WindowsUninstaller.Org Removal Tips
- libvlc media player in C# (part 2)
- vlc-android 获取MediaPlayerEncounteredError,MediaPlayerBuffering等各种事件的响应
- DMediaPlayer - 简单的VLC前端播放器
- VLC media player 官方下载
- VLC Media Player for Android
- libvlc media player in C# (part 1)
- 开源视频播放器VLC media player
- (转)一种开源的跨平台视频开发框架:VideoLAN - VLC media player
- 使用VLC media player搭建简单的流媒体服务器
- libvlc media player in C# (part 2)
- Vlc ReleaseMediaPlayer 异常捕获
- 种开源的跨平台视频开发框架:VideoLAN-VLC media player
- VLC media player for Fedora
- vlc-android 获取MediaPlayerEncounteredError,MediaPlayerBuffering等各种事件的响应
- TS流播放器 开源免费播放器VLC Media Player