From 57b1db4a02faeedfb87c6ace3639c0ab1a9775ae Mon Sep 17 00:00:00 2001 From: Elliot Chen Date: Fri, 19 Apr 2024 17:17:08 +0900 Subject: [PATCH] gstplay: query duration again if previous query failed Part-of: --- subprojects/gst-plugins-bad/gst-libs/gst/play/gstplay.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/play/gstplay.c b/subprojects/gst-plugins-bad/gst-libs/gst/play/gstplay.c index e709ca7572..a6993402f9 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/play/gstplay.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/play/gstplay.c @@ -1443,6 +1443,15 @@ state_changed_cb (G_GNUC_UNUSED GstBus * bus, GstMessage * msg, } } else if (new_state == GST_STATE_PLAYING && pending_state == GST_STATE_VOID_PENDING) { + /* Try to query duration again if needed */ + if (self->cached_duration == GST_CLOCK_TIME_NONE) { + gint64 duration = -1; + + if (gst_element_query_duration (self->playbin, GST_FORMAT_TIME, + &duration)) { + on_duration_changed (self, duration); + } + } /* api_bus_post_message (self, GST_PLAY_MESSAGE_POSITION_UPDATED, */ /* GST_PLAY_MESSAGE_DATA_POSITION, GST_TYPE_CLOCK_TIME, 0, NULL); */