我正在使用vitamio SDK我已编写如下代码,但未调用onCompletion侦听器。
mediaPlayer = new MediaPlayer(this);
Utils.showLog(TAG, "Alert video path to be play : " + path);
mediaPlayer.setDataSource(path);
mediaPlayer.setDisplay(sholder);
mediaPlayer.setBufferSize(1024 * 256);
mediaPlayer.prepareAsync();
mediaPlayer.setWakeMode(getApplicationContext(), PowerManager.PARTIAL_WAKE_LOCK);
mediaPlayer.setOnPreparedListener(this);
mediaPlayer.setOnErrorListener(this);
mediaPlayer.setOnVideoSizeChangedListener(this);
mediaPlayer.setOnInfoListener(this);
并在视频开始后设置onCompletion侦听器
mediaPlayer.setOnCompletionListener(this);
答案 0 :(得分:0)
setOnCompletionListener
上的{p> VideoView
代替MediaPlayer
。
videoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
VideoPlayerActivity.this.finish();
}
});
<强>更新
我认为问题在于你的进口。 导入后仔细检查。
import io.vov.vitamio.MediaPlayer.OnCompletionListener;