Created
August 21, 2014 15:45
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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