0

I have a app that needs to play .mp4 videos.

Here is the code:

try
{
    videoView1 = (VideoView)findViewById(R.id.Video1);
    video= Uri.parse("android.resource://dr.droid/" + R.raw.burn); 
    mc = new MediaController(this);
    videoView1.setMediaController(mc);
    videoView1.setVideoURI(video);
    videoView1.start();
} catch (Exception e) {
    Toast.makeText(getBaseContext(), e.getMessage(), Toast.LENGTH_SHORT).show();
}

I always get an alert cannot play video, But I got no errors. Any ideas?

Dipak Keshariya
  • 22,193
  • 18
  • 76
  • 128
Luke Villanueva
  • 2,030
  • 8
  • 44
  • 94

1 Answers1

0

Just do like this -

String SrcPath = "/sdcard/Video/Android in Spaaaaaace!_low.mp4"; // Instead of this just give your raw folder path. 
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.main);
   VideoView myVideoView = (VideoView)findViewById(R.id.myvideoview);
   myVideoView.setVideoPath(SrcPath);
   myVideoView.setMediaController(new MediaController(this));
   myVideoView.requestFocus();
   myVideoView.start();
}

Hope this will work.

Praveenkumar
  • 24,084
  • 23
  • 95
  • 173