private VideoView videoView;
02.private static final String VIDEO_PATH = Environment
03. .getExternalStorageDirectory()
04. + File.separator
05. + "mymovie"
06. + File.separator + "shenghuaweiji.mp4";
07.
08./** Called when the activity is first created. */
09.@Override
10.public void onCreate(Bundle savedInstanceState) {
11. super.onCreate(savedInstanceState);
12. setContentView(R.layout.main);
13. Log.v("tag", "onCreate");
14.
15. if (videoView == null) {
16. videoView = (VideoView) this.findViewById(R.id.myvideo);
17. MediaController controller = new MediaController(this);
18. videoView.setMediaController(controller);
19. videoView.setVideoPath(VIDEO_PATH);
20. videoView.requestFocus();
21. }
22.
23. if (savedInstanceState != null
24. && savedInstanceState.getInt("currentposition") != 0) {
25.
26. videoView.seekTo(savedInstanceState.getInt("currentposition"));
27. }
28. videoView.start();
29.
30.}
@Override
- protected void onSaveInstanceState(Bundle outState) {
-
- outState.putInt("currentposition", videoView.getCurrentPosition());
- Log.v("tag", "onSaveInstanceState");
- super.onSaveInstanceState(outState);
- }