[java] package cn.c; import java.io.File; import android.app.Activity; import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.os.Environment; import android.view.View; import android.widget.Button; import android.widget.MediaController; import android.widget.VideoView; //利用VideoView播放視頻 //當點擊螢幕的時候在顯示和隱藏間切換 public class MainActivity extends Activity { private Button mButton; private VideoView mVideoView; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mVideoView=(VideoView) findViewById(R.id.videoView); mButton=(Button) findViewById(R.id.button); mButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Uri uri=Uri.parse (Environment.getExternalStorageDirectory().getPath()+File.separator+"Test_Movie.m4v"); mVideoView.setVideoURI(uri); mVideoView.setMediaController(new MediaController(MainActivity.this)); mVideoView.start(); } }); } }