1.在app的gradle文件中添加
compile'fm.jiecao:jiecaovideoplayer:5.5'
compile'com.github.bumptech.glide:glide:3.7.0'
//根据自己的喜好,使用图片加载框架
2.在你的布局文件中添加
<cn.jzvd.JZVideoPlayerStandard
android:id="@+id/videoplayer"
android:layout_width="match_parent"
android:layout_height="200dp"/>
3.在你的播放页面Activity中添加(我添加在onCreate()方法当中)
JCVideoPlayerStandard jcVideoPlayerStandard = (JCVideoPlayerStandard) findViewById(R.id.videoplayer);
jcVideoPlayerStandard.TOOL_BAR_EXIST =false;
jcVideoPlayerStandard.setUp("http://ssb-video.oss-cn- qingdao.aliyuncs.com/Video_1003_20161027140007.mp4", JCVideoPlayerStandard.SCREEN_LAYOUT_NORMAL,"播放视频的标题,可以为空");//播放地址
jcVideoPlayerStandard.loop = true;//是否循环播放
Glide.with(Activity.this).load("视频封面图片地址").into(jzVideoPlayerStandard.thumbImageView);
jcVideoPlayerStandard.widthRatio =4;//播放比例
jcVideoPlayerStandard.heightRatio =3;
//再重写俩个方法
@Override
public void onBackPressed() {
if (JZVideoPlayer.backPress()) {
return;
}
super.onBackPressed();
}
@Override
protected void onPause() {
super.onPause();
JZVideoPlayer.releaseAllVideos();
}
}
4.在AndroidManifest.xml中添加代码
<uses-permission android:name="android.permission.INTERNET"/>
网友评论