<?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">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<VideoView
android:id="@+id/video_view"
android:layout_width="fill_parent"
android:layout_height="300px"
/>
<Button android:id="@+id/cmd_load"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="load"
/>
<Button android:id="@+id/cmd_play"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Play"
/>
<Button android:id="@+id/cmd_pause"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="pause"
/>
</LinearLayout>
package com.eoeandroid.demo.VideoPlayer;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.VideoView;
public class VideoActivity extends Activity {
private static final String TAG = "VideoActivity";
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setTitle("VideoActivity");
Log.v(TAG, "onCreate: ===> ");
setContentView(R.layout.videoplayer);
final VideoView view = (VideoView) findViewById(R.id.video_view);
Button cmdload = (Button) this.findViewById(R.id.cmd_load);
cmdload.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
// TODO Auto-generated method stub
Log.v(TAG, "setVideoPath: ===> ");
view.setVideoPath("/sdcard/xuwei-liwu.3gp");
}
});
Button cmdplay = (Button) this.findViewById(R.id.cmd_play);
cmdplay.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
// TODO Auto-generated method stub
Log.v(TAG, "start: ===> ");
view.start();
}
});
Button cmdpause = (Button) this.findViewById(R.id.cmd_pause);
cmdpause.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
// TODO Auto-generated method stub
Log.v(TAG, "pause: ===> ");
view.pause();
}
});
}
}