我有一個videoView,我想在其中顯示來自URL的MP4視頻。我在Andoird 4.0.2模擬器上試了一下,效果很好。但是,在GingerBread硬件上嘗試時,它崩潰了。我也嘗試過薑餅模擬器,認爲我的設備可能有問題,但仍然沒有進展。當我點擊播放按鈕時,logcat會重複這些操作。MP4視頻不能在Android 2.3上播放
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();
}
}
}
任何幫助將高度讚賞。謝謝。
它不是工作壓力太大:( – 2013-04-12 18:49:14
你是從模擬器或真正的手機嘗試呢? – RonEskinder 2013-04-14 02:11:55
它不能在模擬器和真正的電話都工作。 – 2013-04-14 10:06:46