Android视频播放之JiaoZiVideoPlayer框架的使用
16lz
2021-01-24
1,添加依赖
compile 'cn.jzvd:jiaozivideoplayer:6.2.12'// glide 4.7compile 'com.github.bumptech.glide:glide:4.7.1'annotationProcessor 'com.github.bumptech.glide:compiler:4.7.1'
添加权限:
<uses-permission android:name="android.permission.INTERNET" />
2,布局文件中引入:
<cn.jzvd.JZVideoPlayerStandard android:id="@+id/videoplayer" android:layout_width="match_parent" android:layout_height="200dp"/>
3,设置视频地址、缩略图地址、标题
JZVideoPlayerStandard jzvdStd = (JZVideoPlayerStandard) findViewById(R.id.videoplayer); // 设置这两句切换时会直接进入横屏全屏模式 JZVideoPlayer.FULLSCREEN_ORIENTATION = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; //横向 JZVideoPlayer.NORMAL_ORIENTATION = ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT; //纵向// 设置播放器播放地址,标题 jzvdStd.setUp("http://jzvd.nathen.cn/342a5f7ef6124a4a8faf00e738b8bee4/cf6d9db0bd4d41f59d09ea0a81e918fd-5287d2089db37e62345123a1be272f8b.mp4" ,JZVideoPlayerStandard.SCREEN_WINDOW_NORMAL, "好孩子" ); //设置播放器封面 Glide.with(this) .load("http://jzvd-pic.nathen.cn/jzvd-pic/1bb2ebbe-140d-4e2e-abd2-9e7e564f71ac.png") .into(jzvdStd.thumbImageView);
4,在Activity中:
@Override public void onBackPressed() { if (JZVideoPlayerStandard.backPress()) { return; } super.onBackPressed(); } @Override protected void onPause() { super.onPause(); JZVideoPlayerStandard.releaseAllVideos(); }
5,在AndroidManifest.xml中:
<activity android:name=".MainActivity" android:configChanges="orientation|screenSize|keyboardHidden" android:screenOrientation="portrait" />
更多相关文章
- android 模拟器访问本机http服务IP地址问题
- Android(安卓)webview解析 ,webview点击获取图片地址
- RecycleView 单选 以及多选单选互斥两种状态 和多选
- 【Android】Android开源项目分类汇总
- Cocos2d-x12和NDK-r8编译android
- Android(安卓)程式开发:(一)详解Activity —— 1.3隐藏标题栏
- GitHub 上一些优秀的 Android(安卓)开源项目
- Android(安卓)图文数据JSON解析,金山词霸每日一句API的调用
- android window.requestWindowFeature()常用方法(转)