Display video with VideoView : Video « Media « Android






Display video with VideoView

  


package app.test;

import android.app.Activity;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.widget.VideoView;

public class Test extends Activity {
  VideoView vv;

  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    vv = (VideoView) this.findViewById(R.id.VideoView);
    Uri videoUri = Uri.parse(Environment.getExternalStorageDirectory().getPath()+ "/Test.m4v");
    // Uri videoUri = Uri.parse(Environment.getExternalStorageDirectory().getPath() + "/Test.m4v");
    vv.setVideoURI(videoUri);
    vv.start();
  }
}
//main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
<VideoView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/VideoView"></VideoView>
</LinearLayout>

   
    
  








Related examples in the same category

1.Record video
2.Capture Video
3.Store image and video
4.Load video file from local file system
5.Uri for local video file
6.Custom Video Player
7.Get Video size
8.Using MediaController to control Video
9.Play video from Youtube.com
10.Video Gallery
11.View Video with VideoView
12.Video Capture
13.Video Capture with Metadata
14.VideoView Demo