tags:

views:

3186

answers:

3

Hi,

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 code not working.

import android.app.Activity;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.SurfaceHolder;
import android.view.View;
import android.widget.*;

public class playerActivity extends Activity 
{
Button b;
VideoView preview;
SurfaceHolder holder;
MediaPlayer mp;

 private String path = "/data/data/payoda.android/funny.mp4";

//private String path = "http://www.daily3gp.com/vids/3.3gp";

public void onCreate(Bundle savedInstanceState) 
{
 super.onCreate(savedInstanceState);
 setContentView(R.layout.main);
 preview=(VideoView)findViewById(R.id.surface);
 holder=preview.getHolder();
 b=(Button)findViewById(R.id.cmd_play);
 b.setOnClickListener(new View.OnClickListener()
 {
 public void onClick(View v)
 {
  try
  {
          mp=new MediaPlayer(); 
          mp.setDataSource(path);
          mp.setScreenOnWhilePlaying(true);
          mp.setDisplay(holder);
          mp.prepare();
          mp.start();
  }
  catch(Exception e)
  {

  }
 }
 });
}
}

The Exception thorwn is:

prepare failed:
status=0xC8

The LogCat details are:

09-16 12:16:36.729: ERROR/PlayerDriver(542): Command PLAYER_INIT completed with an error or info PVMFErrContentInvalidForProgressivePlayback
09-16 12:16:36.739: ERROR/MediaPlayer(2867): error (200, -27)

In the above code if change the path variable the Emulator screen is black with single button.May be i have to do some more things to display the video from the Remote URL,i dont know what to do.Any one having any idea about this please help Me.

+1  A: 

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>.

CommonsWare
A: 

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.

Donn Felker
prepareAsync() is also not working.Any other options
Rajapandian
A: 

I'm also having the same problem here (status=0xC8). The 3GP I'm playing to play works on a few mobile phones - except for Android. Since it is a small file I'm trying to play (50KB) and I don't have control over it, is it hard to convert the file for playing after downloading it?

Thanks in advance!

rui pinheiro