-
Notifications
You must be signed in to change notification settings - Fork 1k
常见问题
dueeeke edited this page Mar 19, 2019
·
13 revisions
方法一:修改源码
方法二:内部大部分方法和变量都是public和protected,只需继承它改写相关方法逻辑(推荐)
方法一:修改源码
方法二:继承BaseVideoController或GestureVideoController或StandardVideoController(推荐)
IjkVideoView内部有一个mPlayerContainer的FrameLayout,将你的渲染层添加到里面即可,具体可参考弹幕demo
通过OnVideoViewStateChangeListener接口, 示例如下:
ijkVideoView.addOnVideoViewStateChangeListener(new OnVideoViewStateChangeListener() {
@Override
public void onPlayerStateChanged(int playerState) {
switch (playerState) {
case IjkVideoView.PLAYER_NORMAL://小屏
break;
case IjkVideoView.PLAYER_FULL_SCREEN://全屏
break;
}
}
@Override
public void onPlayStateChanged(int playState) {
switch (playState) {
case IjkVideoView.STATE_IDLE:
break;
case IjkVideoView.STATE_PREPARING:
break;
case IjkVideoView.STATE_PREPARED:
break;
case IjkVideoView.STATE_PLAYING:
break;
case IjkVideoView.STATE_PAUSED:
break;
case IjkVideoView.STATE_BUFFERING:
break;
case IjkVideoView.STATE_BUFFERED:
break;
case IjkVideoView.STATE_PLAYBACK_COMPLETED:
break;
case IjkVideoView.STATE_ERROR:
break;
}
}
});
前提:拥有存储权限,使用file协议,示例如下:
String path = Environment.getExternalStorageDirectory().getAbsolutePath();
String url = "file://" + path + File.separator + "test.mp4";
ijkVideoView.setUrl(url);