I am using the following code to display a video file in the android emulator,it works fine when the video file is stored in a SDcard.But when i give any URL of a video the
you should create a Sdcard in your simulator and then change your eclipse windows view to DDMS chaange your path to mnt/sdcard and push your file onto the device the action buttom is on the right-up of DDMS ,it is a phone icon
then change your .java path
private String path = "mnt/sdcard/funny.mp4";
your should work on it.
First, do not use the emulator for testing video playback. Its ability to handle video playback is very limited. Use an actual Android device.
Second, always check LogCat (adb logcat
, DDMS, or DDMS perspective in Eclipse) for warnings when you run into multimedia problems. OpenCORE -- the multimedia engine used by Android -- has a tendency to log error-level conditions as warnings.
For example, your video file may not be set up for progressive download, which is required for HTTP streaming. On Linux, you can patch up MP4 videos for progressive download by installing MP4Box and running MP4Box -hint <file>
.
You should also use the prepareAsync() method instead of prepare(). Using prepare() is a blocking call (UI gets locked), while prepareAsync is not a blocking call.