7 Mar 2012

Video-Play Local Video in android.

Hello Friends,

Today i am going to post playing video from local directory/Sdcard.

1. Play video from res folder:

public class PlayVideo extends Activity
{
      VideoView videoView ;
      protected void onCreate(Bundle savedInstanceState)
      {

            super.onCreate(savedInstanceState);
            setContentView(R.layout.play_video); 

            videoView = (VideoView) findViewById(R.id.videoView);

            PlayVideo();

      }

      private void PlayVideo()
      {
            try
            {    
                  if(videoView !=null)
                  {
                        getWindow().setFormat(PixelFormat.TRANSLUCENT);    
                        MediaController mediaController = new MediaController(this);
                        mediaController.setAnchorView(videoView);     
                        Uri video = Uri.parse(("android.resource://PkgName/" +R.raw.Videonm));
                        videoView.setMediaController(mediaController);
                        videoView.setVideoURI(video);
                        videoView.start();
                  }

            }

            catch (Exception e)
            {
                  System.out.println("IntroHome Video Ex:"+e.toString());
            }


      }
}


2. Play video from Sdcard:

I will be happy if you will provide your feedback or follow this blog. Any suggestion and help will be appreciated.

Thank you :)

No comments:

Post a Comment