Nada
Nada

Reputation: 5

How to run video in android?

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.

Upvotes: 0

Views: 545

Answers (1)

BoredAndroidDeveloper
BoredAndroidDeveloper

Reputation: 1359

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.

Upvotes: 1

Related Questions