Android视频播放之JiaoZiVideoPlayer框架的使用

版权声明:转载必须注明本文转自郭子轩的博客 https://blog.csdn.net/gpf1320253667/article/details/84744320

1,添加依赖

compile 'cn.jzvd:jiaozivideoplayer:6.2.12'
// glide 4.7
compile 'com.github.bumptech.glide:glide:4.7.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.7.1'

添加权限:

<uses-permission android:name="android.permission.INTERNET" />

2,布局文件中引入:

<cn.jzvd.JZVideoPlayerStandard
        android:id="@+id/videoplayer"
        android:layout_width="match_parent"
        android:layout_height="200dp"/>

3,设置视频地址、缩略图地址、标题

JZVideoPlayerStandard jzvdStd = (JZVideoPlayerStandard) findViewById(R.id.videoplayer);

        // 设置这两句切换时会直接进入横屏全屏模式
        JZVideoPlayer.FULLSCREEN_ORIENTATION = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;  //横向
        JZVideoPlayer.NORMAL_ORIENTATION = ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT;  //纵向

//        设置播放器播放地址,标题
        jzvdStd.setUp("http://jzvd.nathen.cn/342a5f7ef6124a4a8faf00e738b8bee4/cf6d9db0bd4d41f59d09ea0a81e918fd-5287d2089db37e62345123a1be272f8b.mp4"
                ,JZVideoPlayerStandard.SCREEN_WINDOW_NORMAL, "好孩子" );

        //设置播放器封面
        Glide.with(this)
                .load("http://jzvd-pic.nathen.cn/jzvd-pic/1bb2ebbe-140d-4e2e-abd2-9e7e564f71ac.png")
                .into(jzvdStd.thumbImageView);

4,在Activity中:

@Override
    public void onBackPressed() {
        if (JZVideoPlayerStandard.backPress()) {
            return;
        }
        super.onBackPressed();
    }
    @Override
    protected void onPause() {
        super.onPause();
        JZVideoPlayerStandard.releaseAllVideos();
    }

5,在AndroidManifest.xml中:

<activity
    android:name=".MainActivity"
    android:configChanges="orientation|screenSize|keyboardHidden"
    android:screenOrientation="portrait" />

猜你喜欢

转载自blog.csdn.net/gpf1320253667/article/details/84744320