AN VideoPlay

1、用VideoView播放视频

public class MainActivity extends Activity {
    private VideoView videoView;
    private MediaController controller;
	
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
        //requestWindowFeature(Window.FEATURE_NO_TITLE);
        //this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        File file =new  File("/sdcard/mp4/china.mp4");
        if(file.exists()){
        	videoView.setVideoPath(file.getAbsolutePath());
        }
        //相互关联
        controller =new MediaController(this);
        videoView.setMediaController(controller);
        controller.setMediaPlayer(videoView);
        videoView.requestFocus();
		
	}
	
}


你可能感兴趣的:(AN VideoPlay)