jiecaovideoplayer视频播放开源框架的使用步骤

1、使用

1.1 在project的build.gradle添加如下代码和引入lib库

allprojects {
    repositories {
        maven { url "https://jitpack.io" }
    }
}
implementation fm.jiecao:jiecaovideoplayer:5.8.1

1.2 运行所需权限




1.3 布局文件




    

1.4 配置清单文件


            
                
                
            
            
                
                
                
                
            
            
                
                

                
                
            
            
                

                
                

                
                
                
                
                
            
        

1.5 activity 中调运

class JiaoZiVideoPlayerActivity: BaseActivity() {
    override fun getLayoutId(): Int {
        return R.layout.activity_video_player_jiecao
    }

    override fun initData() {
        val data = intent.data;
        if (data == null){
            //从应用内响应http://hc.yinyuetai.com/uploads/videos/common/0FBB016ADECDDFF86FF7D6E8CE792DCC.mp4?sc=c19481d47147e188&br=785&rd=Android
            //获取传递的数据
            var videoUrl = intent.getStringExtra("videoUrl")
            var videoTitle = intent.getStringExtra("videoTitle")
            if(StringHelper.isEmptyString(videoUrl)){
                videoUrl = "http://hc.yinyuetai.com/uploads/videos/common/0FBB016ADECDDFF86FF7D6E8CE792DCC.mp4?sc=c19481d47147e188&br=785&rd=Android"
            }

            videoplayer.setUp(videoUrl, JCVideoPlayerStandard.SCREEN_LAYOUT_NORMAL,videoTitle)
            videoplayer.thumbImageView.setThumbInCustomProject("http://p.qpic.cn/videoyun/0/2449_43b6f696980311e59ed467f22794e792_1/640");
        }else{
            if (data.toString().startsWith("http:")){
                //外部网络视频
                videoplayer.setUp(data.toString(),
                    JCVideoPlayerStandard.SCREEN_LAYOUT_NORMAL,data.toString())
            }else{
                //从应用外响应
                videoplayer.setUp(data.path,
                    JCVideoPlayerStandard.SCREEN_LAYOUT_NORMAL,data.toString())
            }
        }
    }
    override fun onBackPressed() {
        if (JCVideoPlayer.backPress()) {
            return
        }
        super.onBackPressed()
    }

    override fun onPause() {
        super.onPause()
        JCVideoPlayer.releaseAllVideos()
    }
}

你可能感兴趣的:(kotlin,android)