• LZH_IJKPlayer-一个最简单使用的视频播放器,集成于bilibili开源直播播放器(ijkplayer)


         随着视频直播APP的迅速发展,许多APP也都会加入直播的功能,提高用户量。在网上也是寻找了许多直播的播放器,无意间发现Bilibili开源了一款播放器ijkplayer,想从最开始的步骤集成的同学可以点进去查看集成教程。当然,我这里为大家已经都封装好啦,只要简单的几步就可以使用该播放器了。LZH_IJKPlayer点击这个就可以下载源代码了。那如何集成到你的项目中呢。

          1、先看Demo

          将箭头所指的两个文件夹添加到你的工程中。ijkplayer已经打包成framework了,就是图中的IJKMediaFramework

         

        当然以下几个依赖包,肯定是要你重新手动添加的啦。相信大家知道在哪里添加,我就不一一赘述啦。

        

         2、如何使用?再看DEMO

        我把视频播放的视图添加在下面这个控制器中。

        

       打开.m文件,需要实现的跟视频相关的代码如下。

        //初始化视频播放控制器  

        self.playerView = [XYVideoPlayerView videoPlayerView];

        self.playerView.delegate = self;

        [_headPlayerView addSubview:self.playerView];

        self.playerView = self.playerView;

       //视频的Model,将视频地址和视频文件的名称作为Model

        XYVideoModel *model = [[XYVideoModel alloc]init];

        model.url = [NSURL URLWithString:@"http://bos.nj.bpc.baidu.com/tieba-smallvideo/11772_3c435014fb2dd9a5fd56a57cc369f6a.mp4"];

        model.name = @"video1";

        self.playerView.videoModel = model;

    //点击全屏按钮的代理事件   

    - (void)fullScreenWithPlayerView:(XYVideoPlayerView *)videoPlayerView

    {

        if (self.playerView.isRotate) {

            [UIView animateWithDuration:0.3 animations:^{

                _headPlayerView.transform = CGAffineTransformRotate(_headPlayerView.transform, M_PI_2);

                _headPlayerView.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height);

                self.playerView.frame = _headPlayerView.bounds;

                

            }];

            

        }else{        

            [UIView animateWithDuration:0.3 animations:^{

                _headPlayerView.transform = CGAffineTransformIdentity;

                _headPlayerView.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.width*9/16);

                self.playerView.frame = _headPlayerView.bounds;

            }];

        }

    }

    //点击返回按钮的代理事件   

    - (void)backToBeforeVC{

        

        if (!self.playerView.isRotate) {

        

            [self.navigationController popViewControllerAnimated:YES];

        }

    }

    //控制器销毁时必须要实现的方法。 

    - (void)dealloc{

        

        [self.playerView deallocPlayer];

    }

         3、说明

         播放器实现了左半边屏幕上下滑动调节亮度,右半边屏幕,上下滑动调节音量,左右滑动是快进和快退。

         Github源码地址:https://github.com/Harvyluo/LZH_IJKPlayer

       以上就是该播放器的集成过程,使用中有什么问题,可以加官方群。群号:156760711 (LZH_IJKPlayer交流群)     

       欢迎转载,不过请注明该地址,谢谢合作。

  • 相关阅读:
    Scrapy学习-7-数据存储至数据库
    Scrapy学习-6-JSON数据处理
    Scrapy学习-5-下载图片实例
    Scrapy学习-4-Items类&Pipelines类
    Scrapy学习-3-Request回调巧用
    Scrapy学习-2-xpath&css使用
    iTunes.exe 在win7系统中运行出错解决办法
    [转]手机浏览器的User-Agent汇总
    apple mobile device服务无法启动,错误1053 解决
    [转]EF 4.1 Code First
  • 原文地址:https://www.cnblogs.com/blogoflzh/p/5755309.html
Copyright © 2020-2023  润新知