要求:SDK最小版本为16;
defaultConfig {
applicationId "com.example.training"
minSdkVersion 16 //此处修改
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
依赖:
//饺子播放器
implementation 'cn.jzvd:jiaozivideoplayer:6.2.9'
布局
<cn.jzvd.JZVideoPlayerStandard
android:id="@+id/videoplay"
android:layout_width="match_parent"
android:layout_height="200dp"" />
代码:
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);
}