Android播放视频(四)
[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();
}
});
}
}
补充:移动开发 , Android ,