I can recommend using Activity
with VideoView
in layout.
You can save a position when changing orientation, for example,
@Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); if (mVideoView.isPlaying()) outState.putInt("pos", mVideoView.getCurrentPosition()); }
Then restore the position and resume playback in the onCreate method
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.video); mVideoView = (VideoView) findViewById(R.id.video); MediaController mediaController = new MediaController(this); mediaController.setAnchorView(mVideoView); mVideoView.setMediaController(mediaController); mVideoView.setOnCompletionListener(this); Intent intent = getIntent(); path = intent.getExtras().getString("path"); int pos = 0; if (savedInstanceState != null) { pos = savedInstanceState.getInt("pos"); } playVideoFromPos(pos); }
source share