summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gplay.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/gplay.c b/gplay.c
index 26d5f96..5659ee8 100644
--- a/gplay.c
+++ b/gplay.c
@@ -63,6 +63,8 @@ static void update_position_ui()
{
gint64 current;
+ g_return_if_fail(play_state >= GST_STATE_PAUSED);
+
if (!GST_CLOCK_TIME_IS_VALID(media_duration)) {
if (gst_element_query_duration(playbin, GST_FORMAT_TIME, &media_duration)) {
const gdouble seconds = (gdouble)media_duration / GST_SECOND;
@@ -92,6 +94,7 @@ static void reset_position_ui()
gtk_widget_set_sensitive(GTK_WIDGET(slider_widget), FALSE);
gtk_range_set_range(GTK_RANGE(slider_widget), 0.0, 1.0);
gtk_range_set_value(GTK_RANGE(slider_widget), 0.0);
+ media_duration = GST_CLOCK_TIME_NONE;
}
static void open_icon_ready(GObject *source, GAsyncResult *res, gpointer user_data)
@@ -262,7 +265,11 @@ static void bus_handle_error(GstBus *bus, GstMessage *msg, gpointer user_data)
static void bus_handle_eos(GstBus *bus, GstMessage *msg, gpointer user_data)
{
g_debug("End-Of-Stream reached");
- gst_element_set_state(playbin, GST_STATE_READY);
+ // Go back to the initial position
+ gst_element_set_state(playbin, GST_STATE_PAUSED);
+ gst_element_seek_simple(playbin, GST_FORMAT_TIME,
+ GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_KEY_UNIT,
+ 0);
}
static void bus_handle_state_changed(GstBus *bus, GstMessage *msg, gpointer user_data)