我在 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