1.布局文件
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<VideoView
android:id="@+id/videoview"
android:layout_width="match_parent"
android:layout_height="200dp" />
</RelativeLayout>
2.mainactivity
public class MainActivity extends Activity {
private VideoView video;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
video = (VideoView) findViewById(R.id.videoview);
// 设置播放资源
video.setVideoPath("sdcard/zuixuan.flv");
// 开始播放
video.start();
// 播放的控制器
video.setMediaController(new MediaController(MainActivity.this));
}
}