Commit c1833b6b authored by Jean Felder's avatar Jean Felder

gstplayer: Correctly emit "seek-finished" signal

commit 2fa4b631 introduced a
"seek-finished" signal by listening to the reset-time message. The
problem with this approach lies in the fact that the seek operation is
not finished. Thus, the position has not been updated yet and returns
an undefined value.

Fix the issue by moving the signal emission in "_on_async_done"
method. Indeed, an async-done message is sent once the seek operation
is finished. A flag is set when requesting a seek operation to avoid
sending a "seek-finished" signal when an other async operation has
been performed.
parent 48826a6f
Pipeline #89362 passed with stages
in 7 minutes and 59 seconds
......@@ -73,6 +73,7 @@ class GstPlayer(GObject.GObject):
self._application = application
self._duration = -1.
self._seek = False
self._tick = 0
self._missing_plugin_messages = []
......@@ -91,7 +92,6 @@ class GstPlayer(GObject.GObject):
self._bus.connect('message::async-done', self._on_async_done)
self._bus.connect('message::error', self._on_bus_error)
self._bus.connect('message::element', self._on_bus_element)
self._bus.connect('message::reset-time', self._on_reset_time)
self._bus.connect('message::eos', self._on_bus_eos)
self._bus.connect('message::new-clock', self._on_new_clock)
self._bus.connect("message::stream-start", self._on_bus_stream_start)
......@@ -146,11 +146,11 @@ class GstPlayer(GObject.GObject):
else:
self.props.duration = duration
self.notify('state')
if self._seek is True:
self._seek = False
self.emit('seek-finished')
@log
def _on_reset_time(self, bus, message):
self.emit("seek-finished")
self.notify('state')
@log
def _on_new_clock(self, bus, message):
......@@ -303,7 +303,7 @@ class GstPlayer(GObject.GObject):
:param float seconds: Position in seconds to seek
"""
self._player.seek_simple(
self._seek = self._player.seek_simple(
Gst.Format.TIME, Gst.SeekFlags.FLUSH | Gst.SeekFlags.KEY_UNIT,
seconds * Gst.SECOND)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment