Trying to play video from raw folder (VideoView)

Viewed 30495

I can play a video from the Internet by inserting the URL like below:

mPath   = Uri.parse("http://commonsware.com/misc/test2.3gp");
mVid.setVideoURI(mPath);
mVid.requestFocus();
mVid.start();

But now I have a video in my raw folder so the path is res/raw/testing.3gp. The code below doesn't work, and I've tried some other ways too to no avail.

mPath   = Uri.parse("../../res/raw/testing.3gp");

Any suggestions?

4 Answers

You just need to locate song in raw folder under resource folder. if it is link then

 private String urlVideo ="http://www.pocketjourney.com/downloads/pj/video/famous.3gp";

    //Make uri from song located in raw folder
        Uri uri = Uri.parse("android.resource://" + getPackageName() + "/"
                + R.raw.shakebooty);
        player.setUpVideoFrom(uri.toString());

        public void setUpVideoFrom(String source) throws IllegalArgumentException,
                IllegalStateException, IOException {

            mPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);

//Only to check if you want to play song from url
            if (source.contains("http"))
            {
            mPlayer.setDataSource(source);
            }
//If want to play song from uri you created from song in raw folder
        else {
             mPlayer.setDataSource(ctx, source);
             }

        }

Enjoy playing video in surface view

Related