导入依赖
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 ("http://flv3.bn.netease.com/videolib3/1506/03/QufmR3942/SD/QufmR3942-mobile.mp4",
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 ();
}
网友评论