JiaoZiVideoPlayer使用说明

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_39249422/article/details/83828987

饺子视频播放器使用说明

简单的使用

1.添加类库

  compile 'cn.jzvd:jiaozivideoplayer:release'

2.添加布局

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

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

videoView = (JzvdStd) findViewById(R.id.videoplayer);   //初始化控件
videoView.setUp(“视频的链接地址”, “视频的标题”, Jzvd.SCREEN_WINDOW_NORMAL);   //进入小屏幕播放

4.在Activity中

@Override
public void onBackPressed() {
    if (Jzvd.backPress()) {
        return;
    }
    super.onBackPressed();
}

@Override
protected void onPause() {
    super.onPause();
    Jzvd.releaseAllVideos();
}

5.在AndroidManifest.xml中

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

这样就可以播放视频  是不是很简单

基本的使用

1.自动播放

加上这两句就可以进来直接播放了

videoView.startButton.performClick();
videoView.startVideo();

2.播放sd卡下视频

    public void cpAssertVideoToLocalPath() {
        try {
            InputStream myInput;
            OutputStream myOutput = new FileOutputStream(Environment.getExternalStorageDirectory()
                    .getAbsolutePath() + "/DCIM/Camera/local_video.mp4");
            myInput = this.getAssets().open("local_video.mp4");
            byte[] buffer = new byte[1024];
            int length = myInput.read(buffer);
            while (length > 0) {
                myOutput.write(buffer, 0, length);
                length = myInput.read(buffer);
            }

            myOutput.flush();
            myInput.close();
            myOutput.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
myJzvdStd.setUp(Environment.getExternalStorageDirectory().
    getAbsolutePath() + "/DCIM/Camera/local_video.mp4", "饺子不信",Jzvd.SCREEN_WINDOW_NORMAL, );
    
    这里要把URl地址填写正确

3.直接全屏播放

videoView.startFullscreen(this, JzvdStd.class, “视频的链接地址”, “视频的标题”); //进入直接大屏幕播放

4.不保存播放的进度

videoView.SAVE_PROGRESS = false; //当退出页面的时候 清除播放的进度 以免下次进入不从头开始

5.取消播放时在非WIFIDialog提示

videoView.WIFI_TIP_DIALOG_SHOWED=true;

点击全屏按钮闪退,报错空指针

  • 检查是否正确按照基本使用在manifest中配置。Activity是否继承自AppCompatActivity
  • <activity android:name=".activity.VodeoActivity" android:configChanges="orientation|keyboardHidden|screenSize" android:screenOrientation="portrait"/>

这样一个基本的视频播放器就可以使用了   还有很多功能后续再更新

猜你喜欢

转载自blog.csdn.net/qq_39249422/article/details/83828987