tags:

views:

123

answers:

1

I want to play a video from my assets or raw folder in my app in ANDROID using VideoView I am getting the error as video cannot be played please anyone give me a solution.

Here is the code I used

VideoView vd = (VideoView)findViewById(R.id.Video);
Uri uri = Uri.parse("android.resource:" + R.raw.video); MediaController mc = new MediaController(this); vd.setMediaController(mc); vd.setVideoURI(uri); vd.start();

A: 

You must include the package name in the uri:

  Uri uri = Uri.parse("android.resource://[package]/raw/video")

or

  Uri uri = Uri.parse("android.resource://[package]/"+R.raw.video);

Also, check out these examples.

iPaulPro