Reputation: 3111
I'm trying to play a video in a VideoView and I'm failing miserably. I'm working in an Eclipse emulator and am half expecting it not to work there, but when I install my app on my Android phone (version 2.2.1) it also fails. The error message I get is "Cannot play video. Sorry, this video cannot be played." The video is in the Raw folder. Below is my code. parsedData[3].toString() is the name of the video (without the 3gp extension) which is being extracted from a database call. What am I doing wrong?
VideoView videoview = (VideoView) findViewById(R.id.videoView);
videoview.setMediaController(new MediaController(this));
String path = "android.resource://" + getPackageName() + "/R.raw/" + parsedData[3].toString();
videoview.setVideoURI(Uri.parse(path));
videoview.requestFocus();
Upvotes: 1
Views: 11835
Reputation: 2361
You should play videos in SD card (both emulator and device). To push files (videos, audios, images) in Emulator you should see this link: http://www.streamhead.com/android-tutorial-sd-card/
or see this link to try play videos on the link: Trying to play video from raw folder (VideoView)
Upvotes: 2
Reputation: 2361
You can't play video in Raw folder. You should put your video (.3gp, mp4) in SD card of Emulator and play it. Because Emulator just supports playing videos in SD card ( not for Raw like audio). You can see this link: http://android-coding.blogspot.ca/2011/03/using-videoview-to-play-mp4-from-sdcard.html to understand how to play mp4 files in Emulator Android.
Upvotes: 2