我在VideoView上加载.mp4,一切正常,直到我将搜索栏点拖到新位置,因此MediaPlayer开始缓冲,然后应用程序冻结(不崩溃,只是冻结),并显示错误消息:
"无法播放视频"
这是代码:
try {
// Start the MediaController
controller.setAnchorView(videoView);
// Get the URL from String VideoURL
Uri video = Uri.parse(getIntent().getExtras().getString("video"));
videoView.setMediaController(controller);
videoView.setVideoURI(video);
} catch (Exception e) {
Log.e("Error", e.getMessage());
e.printStackTrace();
}
videoView.requestFocus();
videoView.setOnPreparedListener(new OnPreparedListener() {
// Close the progress bar and play the video
public void onPrepared(MediaPlayer mp) {
pDialog.dismiss();
videoView.start();
}
});
如果我寻找已经缓冲的位置,则没有错误。 仅限无缓冲位置。
错误日志:
Attempt to perform seekTo in wrong state: mPlayer=0x5c149090, mCurrentState=0
E/MediaPlayer(17339): error (1, -110)
E/MediaPlayer(17339): Error (1,-110)
D/VideoView(17339): Error: 1,-110