项目介绍:
iOS 自定义基于AVPlayer封装的播放器,全屏切换,切换播放源,添加平移手势以及slider添加单击手势、平移手势,回调使用block,代码尽量简洁。
最新代码地址:LXPlayer)
介绍:[https://www.jianshu.com/p/84abeb68fb62](iOS 基于AVPlayer封装的播放器,全屏切换,切换播放源)
LXPlayModel *model =[[LXPlayModel alloc]init];
model.playUrl = @"http://wvideo.spriteapp.cn/video/2016/0328/56f8ec01d9bfe_wpd.mp4";
model.videoTitle = @"蝙蝠侠大战大灰狼";
model.fatherView = self.playFatherView;
self.playerview =[[LXAVPlayView alloc]init];
self.playerview.isLandScape = NO;
self.playerview.isAutoReplay = NO;
self.playerview.currentModel = model;
LXWS(weakSelf);
self.playerview.backBlock = ^{
[weakSelf dismissViewControllerAnimated:YES completion:nil];
};
LxButton *nextBtn =[LxButton LXButtonWithTitle:@"下一集" titleFont:Font(15) Image:nil backgroundImage:nil backgroundColor:[UIColor redColor] titleColor:[UIColor whiteColor] frame:CGRectMake(0, Device_Height -40, 120, 40)];
[self.view addSubview:nextBtn];
[nextBtn addClickBlock:^(UIButton *button) {
LXPlayModel *model =[[LXPlayModel alloc]init];
model.playUrl = @"http://wvideo.spriteapp.cn/video/2016/0709/5781023a979d7_wpd.mp4";
model.videoTitle = @"陈二狗的妖孽人生";
model.fatherView = weakSelf.playFatherView;
weakSelf.playerview.currentModel = model;
}];
LxButton *nextBtn2 =[LxButton LXButtonWithTitle:@"上一集" titleFont:Font(15) Image:nil backgroundImage:nil backgroundColor:[UIColor redColor] titleColor:[UIColor whiteColor] frame:CGRectMake(Device_Width -120, Device_Height -40, 120, 40)];
[self.view addSubview:nextBtn2];
//http://vip.okokbo.com/20180117/BNp2mT7Q/index.m3u8
//http://down.4xx.me/test.mp4
[nextBtn2 addClickBlock:^(UIButton *button) {
LXPlayModel *model =[[LXPlayModel alloc]init];
model.playUrl = @"http://vip.okokbo.com/20180117/BNp2mT7Q/index.m3u8";
model.videoTitle = @"寻梦环游记";
model.fatherView = weakSelf.playFatherView;
weakSelf.playerview.currentModel = model;
}];
}
-(void)viewWillDisappear:(BOOL)animated{
[super viewWillDisappear:animated];
[self.playerview destroyPlayer];
}