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);
mediaController.setAnchorView(contentView);
Uri uri=Uri.parse("android.resource://"+getPackageName()+"/"+R.raw.video_name);
((VideoView) contentView).setMediaController(mediaController);
((VideoView) contentView).setVideoURI(uri);
contentView.requestFocus();
((VideoView) contentView).start();
Hope this helps someone.
No comments:
Post a Comment