Play .MP4 video from raw resource folder

I have seen a number of similar questions, but so far I have not been able to do anything.

I am trying to play a video (.MP4) from a res / raw folder and receive only audio, without video. The video is short (about 3 seconds), small (350 KB), and if I put the video on the device (Motorola Droid) directly, it works fine. It also works great if I modify the application to read it from an SD card and not from a resource folder. The behavior is the same on the emulator and on the device itself.

Unfortunately, I need this video to be shown intro directly in front of the main screen for my application, so it should be part of the package. In addition, one of the requirements for applications is that the application is available offline, so I can not transfer from the web server. I tried VideoView, SurfaceView and MediaPlayer, none of them work.

Can I play a video from a resource folder? I read something about compression, perhaps screwing a video, is it possible to manually unzip the video and then play it, and if so, how will it work? It seems like it should be a fairly simple operation, did I just miss something?

+4
source share
1 answer

I had the same problems, I tried it too, I agree that this should be easier ... and documented. Just fixed by passing the VideoView.setVideoUri line with the android.resource protocol, as described here . The first option does not work for me, but the second does:
Uri uri = Uri.parse("android.resource://[package]/"+R.raw.[video_resid]);
I hope you will work too.

+12
source

All Articles