NullPointerException
NullPointerException

Reputation: 37701

Exists a easy way to play MP4 videos on Android 1.5? (compatible with higher versions of the SO)

I need to play a short MP4 video when my app starts.

I'm searching info about how to load mp4 videos but I can't find the way to do it on Android 1.5

My app should be compatible from Android 1.5 to 4.0

Exists a easy way to play MP4 videos on Android 1.5?

Thanks

Upvotes: 0

Views: 427

Answers (1)

Jakub Szczygieł
Jakub Szczygieł

Reputation: 1232

You can use VideoView. Create object and set uri to video. If you are trying to play video from res folder use this URI pareser:

Uri video = Uri.parse("android.resource://com.pac.myapp/raw/video_name");

Where com.pac.myapp is your app package name and video_name is name of your video file under raw folder.

After you get uri use it with videoview function

setVideoURI(Uri uri)

If you want video to start playing after activity is visible, override onvisibilistychange function of activity, and start playing as you get true from function parameter.

EDIT

VideoView view=(VideoView) findViewById(R.id.video_view);
Uri videPath=Uri.parse("android.resource://com.example.myapp/raw/1");
view.setVideoUri(videoPath);

That should work, if you get exception please paste it here. I will gladly help.

Upvotes: 1

Related Questions