Skip to content

Instantly share code, notes, and snippets.

@justasm
Created August 21, 2014 15:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justasm/8c7147555994d14f2ef2 to your computer and use it in GitHub Desktop.
Save justasm/8c7147555994d14f2ef2 to your computer and use it in GitHub Desktop.
Android video playback - using VideoView to play file from res/raw/ & MediaController for playback control.
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<VideoView
android:id="@+id/videoView1"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>
package com.example.videotest;
import android.app.Activity;
import android.net.Uri;
import android.os.Bundle;
import android.widget.MediaController;
import android.widget.VideoView;
public class VideoPlaybackActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_video_playback);
VideoView vv = (VideoView) findViewById(R.id.videoView1);
MediaController mc = new MediaController(this);
vv.setMediaController(mc);
vv.setVideoURI(Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.video_file_name));
vv.start();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment