-
Notifications
You must be signed in to change notification settings - Fork 1k
常见问题
dueeeke edited this page Nov 27, 2019
·
13 revisions
参考demo中ijkVideoView和ExoVideoView实现
继承GestureVideoController,需完全自定义ui,需要手势操作的情形; 继承StandardVideoController,部分自定义的情形,重写相关方法; 使用ControlComponent,参考demo和dkplayer-ui这个库的实现方式。
VideoView内部有一个mPlayerContainer的FrameLayout,将你的渲染层添加到里面即可,具体可参考弹幕demo
通过OnVideoViewStateChangeListener接口, 示例如下:
VideoView.addOnVideoViewStateChangeListener(new OnVideoViewStateChangeListener() {
@Override
public void onPlayerStateChanged(int playerState) {
switch (playerState) {
case VideoView.PLAYER_NORMAL://小屏
break;
case VideoView.PLAYER_FULL_SCREEN://全屏
break;
}
}
@Override
public void onPlayStateChanged(int playState) {
switch (playState) {
case VideoView.STATE_IDLE:
break;
case VideoView.STATE_PREPARING:
break;
case VideoView.STATE_PREPARED:
break;
case VideoView.STATE_PLAYING:
break;
case VideoView.STATE_PAUSED:
break;
case VideoView.STATE_BUFFERING:
break;
case VideoView.STATE_BUFFERED:
break;
case VideoView.STATE_PLAYBACK_COMPLETED:
break;
case VideoView.STATE_ERROR:
break;
}
}
});
前提:拥有存储权限,示例如下:
String path = Environment.getExternalStorageDirectory().getAbsolutePath();
String url = "file://" + path + File.separator + "test.mp4";
videoView.setUrl(url);
参考demo中IjkVideoView的实现