0
VideoView videoView = (VideoView) findViewById(R.id.butterfly);
        videoView.setVideoPath("res/raw/butterfly");
        videoView.setMediaController(new MediaController(this));
        videoView.requestFocus();
        videoView.start();
        MediaPlayer mp = MediaPlayer.create(this,R.raw.butterfly);
        mp.start();

In my application I need to run multiple video, I used this code and it does not work, when I run it the emulator couldn't show the selected video.

Nada
  • 5
  • 5
  • where is your video ??? `butterfly is video` there are no any extension like `.mp4,.3gp` – Samir Mangroliya Mar 26 '12 at 18:25
  • @nada : set `setVideoPath` as using `Uri video = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.butterfly);` – ρяσѕρєя K Mar 26 '12 at 18:29
  • @Nada : or see this maybe helpful[How to play videos in android from assets folder or raw folder](http://stackoverflow.com/questions/3028717/how-to-play-videos-in-android-from-assets-folder-or-raw-folder) – ρяσѕρєя K Mar 26 '12 at 18:32

1 Answers1

1

Unless there's some security reason not to let your users use a different video app.. then launch it in as an intent:

startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(VIDEO_URL)));

That way if they have an app that will do things like stream it to their TV then they can use that instead of your player. If you limit them to your app then in the end they might not like the usability of your app.

When they hit back it will go to your app again.

BoredAndroidDeveloper
  • 1,251
  • 1
  • 11
  • 26