All Things Techie With Huge, Unstructured, Intuitive Leaps

Android Media Player Snippet

I recently tested a bit of code with an Android media player .  The Java code is quite simple.  Toss a media player in layout.xml, import an mp4 video into the raw folder,  and then put the following code in your onCreate() method in the activity:

MediaController mediaController= new MediaController(this);
   Uri uri=Uri.parse("android.resource://"+getPackageName()+"/"+R.raw.video_name);        
   ((VideoView) contentView).setMediaController(mediaController);
   ((VideoView) contentView).setVideoURI(uri);        

   ((VideoView) contentView).start();

Hope this helps someone.

No comments:

Post a Comment