第一次使用JZVideoPlayerStandard播放器

第一次使用JZVideoPlayerStandard播放器

给自己记录一下,万一以后还用,就可以直接CV了

首先添加依赖 implementation ‘cn.jzvd:jiaozivideoplayer:6.2.4’

在AndroidManifest里一定要添加(否则全屏会报错)
android:configChanges=“orientation|screenSize|keyboardHidden”
android:screenOrientation=“portrait”

布局文件
android:layout_width=“match_parent”
android:layout_height="@dimen/dp200"
android:id="@+id/jz_player_standard">

代码中:
创建
SensorManager sensorManager;
public JZVideoPlayerStandard jzPlayerStandard;
JZVideoPlayer.JZAutoFullscreenListener jzAutoFullscreenListener;

				//用于实现重力感应下切换横竖屏
                 sensorManager = (SensorManager) context.getSystemService(SENSOR_SERVICE);
                 jzAutoFullscreenListener = new JZVideoPlayer.JZAutoFullscreenListener();
					
                    JZVideoPlayer.FULLSCREEN_ORIENTATION = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;  //横向
                    //设置图片为全屏
                    jzPlayerStandard.thumbImageView.setScaleType(ImageView.ScaleType.FIT_XY);
                    //内置视频的高度,可以去除黑边
                    JZVideoPlayer.setVideoImageDisplayType(JZVideoPlayer.VIDEO_IMAGE_DISPLAY_TYPE_FILL_PARENT);
                    //播放视频
                    jzPlayerStandard.TOOL_BAR_EXIST = true;

					//videourl 为在线视频地址
					jzPlayerStandard.setUp(videourl, JZVideoPlayerStandard.SCROLL_AXIS_HORIZONTAL, "");
					//cover为在线图片地址  (视频未播放时的展示图片)
    				Glide.with(context).load(cover).into(jzPlayerStandard.thumbImageView);


				jzPlayerStandard.SAVE_PROGRESS = false;//停止播放
				jzPlayerStandard.SAVE_PROGRESS = true;//开始播放

你可能感兴趣的:(第一次使用JZVideoPlayerStandard播放器)