饺子播放器是android主流播放器中之一,使用简单,功能全面。
不要按照github文档来,api有变动。
常见问题
ERROR: Manifest merger failed : uses-sdk:minSdkVersion 15 cannot be smaller than version 16
declared in library [cn.jzvd:jiaozivideoplayer:6.2.9]
要求sdk最小版本为16
解决:
defaultConfig {
applicationId "com.example.day16_video"
minSdkVersion 16 // 修改处
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
使用
1.依赖
这个地方也要添加glide的依赖,因为视频默认图需要glide加载。
implementation 'cn.jzvd:jiaozivideoplayer:6.2.9'
2.布局
<cn.jzvd.JZVideoPlayerStandard
android:id="@+id/videoplayer"
android:layout_width="match_parent"
android:layout_height="200dp" />
3.代码
public void jiaoziPlayer(){
String mp4path = Environment.getExternalStorageDirectory() + File.separator + "xxx.mp4";
JZVideoPlayerStandard jzVideoPlayerStandard = (JZVideoPlayerStandard) findViewById(R.id.videoplayer);
jzVideoPlayerStandard.setUp(mp4path
, JZVideoPlayerStandard.SCREEN_WINDOW_NORMAL, "饺子闭眼睛");
jzVideoPlayerStandard.thumbImageView.setImageResource(R.drawable.ic_launcher_background);
}
效果