2012年8月17日 星期五

VideoView



影片

public class Cq_VideoViewActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
     
        VideoView videoview = (VideoView)findViewById(R.id.videoView1);
        videoview.setVideoPath("/sdcard/external_sd/GirlWePursued.m4v");
        MediaController mc = new MediaController(this);
        videoview.setMediaController(mc);
        videoview.requestFocus();
        videoview.start();
    }
}

*********************************************
res/layout/main.xml


<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:id="@+id/TableLayout01"
    android:gravity="center" >

    <VideoView
        android:id="@+id/videoView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

</TableLayout>


沒有留言:

張貼留言