我有一个 videoView,我想在其中显示来自 URL 的 MP4 视频。我在 Andoird 4.0.2 模拟器上试过,效果很好。然而,在 A GingerBread 硬件上尝试它时,它崩溃了。我还在 Gingerbread 模拟器上尝试过,认为我的设备可能有问题,但仍然没有进展。当我点击播放按钮时,logcat 会一次又一次地重复这些操作。
04-11 23:49:27.438: V/VideoViewDemo(413): path: http://173.193.24.66/~kanz/video/mp4/9.mp4
04-11 23:49:28.796: D/MediaPlayer(413): Couldn't open file on client side, trying server side
04-11 23:49:38.207: D/MediaPlayer(413): getMetadata
04-11 23:49:39.343: W/MediaPlayer(413): info/warning (701, 0)
04-11 23:49:39.346: I/MediaPlayer(413): Info (701,0)
04-11 23:49:45.556: W/MediaPlayer(413): info/warning (702, 0)
04-11 23:49:45.556: I/MediaPlayer(413): Info (702,0)
04-11 23:51:11.467: W/MediaPlayer(413): info/warning (701, 0)
04-11 23:51:11.467: I/MediaPlayer(413): Info (701,0)
04-11 23:51:22.096: W/MediaPlayer(413): info/warning (702, 0)
04-11 23:51:22.096: I/MediaPlayer(413): Info (702,0)
04-11 23:51:25.636: W/MediaPlayer(413): info/warning (701, 0)
04-11 23:51:25.636: I/MediaPlayer(413): Info (701,0)
04-11 23:51:37.127: W/MediaPlayer(413): info/warning (702, 0)
04-11 23:51:37.127: I/MediaPlayer(413): Info (702,0)
04-11 23:51:41.717: W/MediaPlayer(413): info/warning (701, 0)
04-11 23:51:41.717: I/MediaPlayer(413): Info (701,0)
04-11 23:51:54.086: W/MediaPlayer(413): info/warning (702, 0)
04-11 23:51:54.097: I/MediaPlayer(413): Info (702,0)
它没有显示任何错误,因此我可以知道是哪一行导致了问题。这是播放按钮的代码:
try {
final String path = mPath.getText().toString();
Log.v(TAG, "path: " + path);
if (path == null || path.length() == 0) {
Toast.makeText(MainActivity.this, "File URL/path is empty",
Toast.LENGTH_LONG).show();
} else {
// If the path has not changed, just start the media player
if (path.equals(current) && mVideoView != null) {
mVideoView.setVideoURI(Uri.parse("http://173.193.24.66/~kanz/video/mp4/9.mp4"));
mVideoView.requestFocus();
mVideoView.start();
return;
}
current = path;
mVideoView.setVideoURI(Uri.parse(getDataSource(path)));
mVideoView.requestFocus();
mVideoView.start();
}
} catch (Exception e) {
Log.e(TAG, "error: " + e.getMessage(), e);
if (mVideoView != null) {
mVideoView.stopPlayback();
}
}
}
任何帮助将不胜感激。谢谢。