dev90
dev90

Reputation: 7519

VideoView is unable to play video from Resource

I have checked other questions, and applied the solution available in them, but still it is not working.

I have placed a video in my raw folder. I am getting the video by using following method

String path = "android.resource://" + getPackageName() + "/"+ R.raw.splash_video;

videoView= (VideoView) findViewById(R.id.splash_videoView);

Uri uri= Uri.parse(path);
videoView.setVideoURI(uri);
videoView.start();

The video is in mp4 format, When i run my program, it displays me Can't play the video message.

When i debug the code, i found out that, it changes the path value to this:

path= android.resource:///2131099757

If i change the path to Some URL, it successfully plays the video.

String path= "www.abc.com/someVideo.mp4"

Kindly guide me how to play mp4 video from raw

Upvotes: 1

Views: 1993

Answers (1)

Jay Rathod
Jay Rathod

Reputation: 11245

Try with this URL.

String uriPath = "android.resource://"+getPackageName()+"/raw/myvideo";

Where myvideo is your video file name.

Upvotes: 1

Related Questions