ArK
ArK

Reputation: 21058

Android video restarted with orientation

How to avoid reloading of video with orientation change i.e force the video to resume from same.

i have tried below but it fails

vd = (VideoView) findViewById(R.id.vplayer);
.......
public void onSaveInstanceState(Bundle savedInstanceState) {
    super.onSaveInstanceState(savedInstanceState);
    savedInstanceState.putInt("Position",vd.getCurrentPosition());
}

public void onRestoreInstanceState(Bundle savedInstanceState) {
    super.onRestoreInstanceState(savedInstanceState);
    int position= savedInstanceState.getInt("Position");
    vd.seekTo(position);
}

Upvotes: 4

Views: 2296

Answers (1)

Lalit Poptani
Lalit Poptani

Reputation: 67286

What you can do is stop your Activity to get re-created when orientation changes. You can do that by adding in your AndroidManifest.xml file in the activity tag

android:configChanges="keyboardHidden|orientation"

Upvotes: 7

Related Questions