欢迎光临
我们一直在努力

iOS 基于AVPlayer封装的播放器,全屏切换,切换播放源

建站超值云服务器,限时71元/月

iOS 基于AVPlayer封装的播放器,全屏切换,切换播放源

项目介绍:

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];  
}  

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » iOS 基于AVPlayer封装的播放器,全屏切换,切换播放源
分享到: 更多 (0)