Wednesday, July 8, 2015

Play Video (mp4,3gp,etc) From Resource (old)

  1. put your mp4 file into folder res/raw (you need to create folder raw under folder res)
    For example d:\workspace\Test\res\raw
    Application Name: Test
    mp4 file name: gayatrimantra.mp4
    full path filename: d:\workspace\Test\res\raw\gayatrimantra.mp4
  2. to start your Video, write this code
        public void ClickDeh(View view)
        {
            VideoView videoview = (VideoView) findViewById(R.id.videoView1);
          
            Uri uri = Uri.parse("android.resource://"+getPackageName()+"/"+R.raw.gayatrimantra);
                  
            videoview.setVideoURI(uri);
            videoview.start();      
        }

Note: File name must be unique
Source: http://www.androidsnippets.com/play-video-file-from-resources

No comments:

Post a Comment