JZVedioPlayer又叫饺子播放器:
导入依赖
implementation 'cn.jzvd:jiaozivideoplayer:6.2.4'
设置布局
<fm.jiecao.jcvideoplayer_lib.JCVideoPlayerStandard
android:id="@+id/videocontroller1"
android:layout_width="match_parent"
android:scaleType="fitXY"
android:layout_height="200dp" />
实现代码
//饺子播放器
private void initView() {
mJzvideo = (JZVideoPlayerStandard) findViewById (R.id.jzvideo);
//设置视频
mJzvideo.setUp ("https://vd2.bdstatic.com/mda-jgrg8z7wwvrqyfsx/sc/mda-jgrg8z7wwvrqyfsx.mp4?auth_key=1565251144-0-0-9bf7b45da92c8b085b6681f144a319e7&bcevod_channel=searchbox_feed&pd=bjh&abtest=all",
mJzvideo.SCREEN_WINDOW_NORMAL,
""//标题
);
//设置背景图片没有黑边
mJzvideo.thumbImageView.setImageResource (R.drawable.ic_action_navigation_arrow_back);
JZVideoPlayer.setVideoImageDisplayType(JZVideoPlayer.VIDEO_IMAGE_DISPLAY_TYPE_FILL_PARENT);
//视频第一帧图片
Glide.with(this).load("http://p0.so.qhmsg.com/bdr/_240_/t01c10808f98a39bd4f.jpg")
.into(mJC.thumbImageView);
播放比例,可以设置为16:9,4:3
mJC.widthRatio = 4;
mJC.heightRatio = 3;
}
释放资源
@Override
protected void onPause() {
super.onPause ();
//暂停释放资源
JZVideoPlayerStandard.releaseAllVideos ();
}
网友评论