Android-播放视频简单案例

layout.xml

<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

  <VideoView
  android:id="@+id/videoView"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent" />

</AbsoluteLayout>

 

Src:

VideoView videoView ;
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  requestWindowFeature(Window.FEATURE_NO_TITLE);
  getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);//设置成全屏模式
  setContentView(R.layout.play_layout);

  videoView = (VideoView) findViewById(R.id.videoView);
  videoView.setMediaController(new MediaController(this));
  Uri videoUri = Uri.parse(Environment.getExternalStorageDirectory().getPath() + "/raw/my_video/a.mp4");
  videoView.setVideoURI(videoUri);
  videoView.start();

}

posted @ 2015-11-11 17:22  David_cheng  阅读(227)  评论(0编辑  收藏  举报