diff --git a/gst-sdk/tutorials/android-tutorial-1/jni/tutorial-1.c b/gst-sdk/tutorials/android-tutorial-1/jni/tutorial-1.c index 573212c76f..038699a48c 100755 --- a/gst-sdk/tutorials/android-tutorial-1/jni/tutorial-1.c +++ b/gst-sdk/tutorials/android-tutorial-1/jni/tutorial-1.c @@ -154,7 +154,7 @@ static void state_changed_cb (GstBus *bus, GstMessage *msg, CustomData *data) { if (GST_MESSAGE_SRC (msg) == GST_OBJECT (data->pipeline)) { set_message (gst_element_state_get_name (new_state), data); data->state = new_state; - if (data->state == GST_STATE_PLAYING && GST_CLOCK_TIME_IS_VALID (data->desired_position)) { + if (data->state >= GST_STATE_PAUSED && GST_CLOCK_TIME_IS_VALID (data->desired_position)) { execute_seek (data->desired_position, data); data->desired_position = GST_CLOCK_TIME_NONE; } @@ -240,6 +240,9 @@ static void *app_function (void *userdata) { /* Register a function that GLib will call every second */ timeout_source_id = g_timeout_add_seconds (1, (GSourceFunc)refresh_ui, data); + /* Set state to PAUSE, so preroll occurrs and retrieve some information like clip length */ + gst_element_set_state (data->pipeline, GST_STATE_PAUSED); + /* Create a GLib Main Loop and set it to run */ GST_DEBUG ("Entering main loop... (CustomData:%p)", data); data->main_loop = g_main_loop_new (NULL, FALSE); diff --git a/gst-sdk/tutorials/android-tutorial-1/src/com/gst_sdk_tutorials/tutorial_1/Tutorial1.java b/gst-sdk/tutorials/android-tutorial-1/src/com/gst_sdk_tutorials/tutorial_1/Tutorial1.java index a344b75063..e82055a7bb 100755 --- a/gst-sdk/tutorials/android-tutorial-1/src/com/gst_sdk_tutorials/tutorial_1/Tutorial1.java +++ b/gst-sdk/tutorials/android-tutorial-1/src/com/gst_sdk_tutorials/tutorial_1/Tutorial1.java @@ -79,12 +79,14 @@ public class Tutorial1 extends Activity implements SurfaceHolder.Callback, OnSee nativeInit(); - playing = savedInstanceState==null ? false : savedInstanceState.getBoolean("playing"); - if (playing) { + if (savedInstanceState != null) { + playing = savedInstanceState.getBoolean("playing"); int milliseconds = savedInstanceState.getInt("position"); - Log.i ("GStreamer", "Restoring to playing state at " + milliseconds + " ms."); - nativePlay(); + Log.i ("GStreamer", "Restoring state, playing:" + playing + " position:" + milliseconds + " ms."); nativeSetPosition(milliseconds); + if (playing) { + nativePlay(); + } } }