1.引入依赖库
2.播放地址
_dataArray = @[@"rtmp://live.hkstv.hk.lxdns.com/live/hks",@"rtmp://202.69.69.180:443/webcast/bshdlive-pc",@"rtmp://123.108.164.71/etv2/phd926",@"rtmp://122.202.129.136:1935/live/ch5",@"rtmp://live.chosun.gscdn.com/live/tvchosun1.stream",@"rtmp://110.164.48.237:1935/tcctv_ch002/tcctv02.stream_live1",@"rtmp://media3.sinovision.net:1935/live/livestream",@"rtmp://tv.unbtv.tv/app_2/ls_1.stream"];
<span style="font-family: Arial, Helvetica, sans-serif;">_titleArray = @[@"香港卫视",@"香港财经",@"韩国新唐人亚太",@"韩国KCTV-HD",@"韩国朝鲜日报",@"泰国中文台",@"美国中文电视",@"亚洲联合卫视",@"深圳"];//测试后这些地址是能播放的。</span>
3.传入播放地址开始播饭
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor whiteColor];
[self.view addSubview:self.palerView];
_vlePlayer = [[VLCMediaPlayer alloc]initWithOptions:nil];
_vlePlayer.drawable = _palerView;
[_palerView setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight];
VLCMedia *media = [VLCMedia mediaWithURL:[NSURL URLWithString:self.url]];
[_vlePlayer setMedia:media];
[_vlePlayer play];
}
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear: animated];
[_vlePlayer stop];
}
#pragma mark ---getter
- (UIView *)palerView
{
if(!_palerView)
{
_palerView = [[UIView alloc]initWithFrame:self.view.bounds];
}
return _palerView;
}
效果: