#import <MobileVLCKit/MobileVLCKit.h>
@property (nonatomic, strong) VLCMediaPlayer * player;
@property(nonatomic,strong) UIView *playView; //播放区域
// vlc播放器
- (void)initMediaPlayer:(NSString *)urlStr {
UIView *playView = [[UIView alloc] initWithFrame:CGRectMake(0, 100, self.view.frame.size.width, 200)];
playView.backgroundColor = [UIColor redColor];
[self.view addSubview:playView];
VLCMediaPlayer * player = [[VLCMediaPlayer alloc] initWithOptions:nil];
self.player = player;
player.delegate = self;
player.drawable = playView;
player.media = [VLCMedia mediaWithURL:[NSURL URLWithString:urlStr]];
[player play];
}
// 当时间发生改变时,可以在该方法中去调用获取播放时间和剩余时间
-(void)mediaPlayerTimeChanged:(NSNotification *)aNotification {
}
// 当播放状态发生改变时
- (void)mediaPlayerStateChanged:(NSNotification *)aNotification {
}
调用
/*
rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mp4
http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8
http://devimages.apple.com/iphone/samples/bipbop/gear3/prog_index.m3u8
https://devimages.apple.com.edgekey.net/streaming/examples/bipbop_4x3/bipbop_4x3_variant.m3u8
作者:i舒克
链接:https://www.jianshu.com/p/20f9e9bb89aa
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
*/
NSString *urlStr = @"http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8";
[self initMediaPlayer:urlStr];