在此示例中,视频在暂停时停留在最后一帧,并且永远不会再次启动。它永远不会进入setOnPreparedListener。
public void pauseVideo(){
videoPos=videoView.getCurrentPosition();
Log.w("Video Position", Integer.toString(videoPos));
isVideoPaused=true;
videoView.pause();
}
public void resumeVideo(){
Log.w("Video Pos in resume", Integer.toString(videoPos));
videoView.seekTo(videoPos);
videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
Log.w("Inside on prepared","finally inside");
mp.setOnSeekCompleteListener(new MediaPlayer.OnSeekCompleteListener() {
@Override
public void onSeekComplete(MediaPlayer mp) {
Log.w("Inside on seek complete","finally inside");
videoView.start();
}
});
}
});
}
答案 0 :(得分:1)
无需设置setOnPreparedListener
,只需使用以下代码:
videoView.seekTo(video_pos);
videoView.start();