Issue
I have a videoView in which I want to display an MP4 video from a URL. I tried it on Andoird 4.0.2 emulator and it worked fine. However, on trying it on A GingerBread hardware, it crashed. I also tried it on Gingerbread emulator, thinking there could be something wrong with my device, but still no progress. The logcat is repeating these again and again when I tap the Play button.
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)
It isn't showing any error so that I can know which line is exactly causing the problem. Here's the Play button's code:
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();
}
}
}
Any help would be highly appreciated. Thanks.
Solution
You may want to try this code,
String videoSource = "http://173.193.24.66/~kanz/video/mp4/9.mp4";
myVideoView.setMediaController(new MediaController(this));
myVideoView.setVideoPath(videoSource);
myVideoView.requestFocus();
myVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
public void onPrepared(MediaPlayer mp) {
myVideoView.start();
}
});
Answered By - RonEskinder
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.