Rotating phone restarts video on android
Adding the configChanges
attribute to your manifest means that you will handle config changes yourself. Override the onConfigurationChanged()
method in your activity:
int lastOrientation = 0;
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
// Checks if orientation changed
if (lastOrientation != newConfig.orientation) {
lastOrientation = newConfig.orientation;
// redraw your controls here
}
}
Consider remembering video file position in Activity lifecycle events. When Activity is created you could obtain video position and play it from the moment it was restarted.
In your Activity class:
@Override
protected void onCreate(Bundle bundle){
super.onCreate(bundle);
int mPos=bundle.getInt("pos"); // get position, also check if value exists, refer to documentation for more info
}
@Override
protected void onSaveInstanceState (Bundle outState){
outState.putInt("pos", myVideoView.getCurrentPosition()); // save it here
}
add
android:configChanges="orientation"
to your Activity in AndroidManifest.xml.
- solved my issue won't download progressive video again..
If your target API level 13 or higher, you must include the screenSize
value in addition to the orientation
value as described here. So your tag may look like
android:configChanges="orientation|screenSize"