Fix restoration of playing state after orientation change

This commit is contained in:
Xavi Artigas 2012-10-01 14:27:25 +02:00
parent af9437ff7d
commit 76c883fb8b

View file

@ -131,16 +131,16 @@ public class Tutorial1 extends Activity implements SurfaceHolder.Callback, OnSee
if (mediaUri.startsWith("file://")) is_local_media = true;
if (initialization_data != null) {
boolean should_play = initialization_data.getBoolean("playing");
is_playing_desired = initialization_data.getBoolean("playing");
int milliseconds = initialization_data.getInt("position");
Log.i ("GStreamer", "Restoring state, playing:" + should_play + " position:" + milliseconds + " ms.");
Log.i ("GStreamer", "Restoring state, playing:" + is_playing_desired + " position:" + milliseconds + " ms.");
/* Actually, move to one millisecond in the future. Otherwise, due to rounding errors between the
* milliseconds used here and the nanoseconds used by GStreamer, we would be jumping a bit behind
* where we were before. This, combined with seeking to keyframe positions, would skip one keyframe
* backwards on each iteration.
*/
nativeSetPosition(milliseconds + 1);
if (should_play) {
if (is_playing_desired) {
nativePlay();
} else {
nativePause();