Commit 2fa4b631 authored by Jean Felder's avatar Jean Felder

player: Fix signal emission after a seek operation

As the seek_simple operation is asynchronous, the seek-finished signal
cannot directly be emitted by the Player.

Fix the issue by listening to the reset-time message in
GstPlayer. This message is sent once the seek_simple operation is
finished. The seek-finished signal is then transmitted to the Player.
parent 4804e73f
Pipeline #86940 passed with stages
in 7 minutes and 47 seconds
...@@ -51,7 +51,8 @@ class GstPlayer(GObject.GObject): ...@@ -51,7 +51,8 @@ class GstPlayer(GObject.GObject):
""" """
__gsignals__ = { __gsignals__ = {
'eos': (GObject.SignalFlags.RUN_FIRST, None, ()), 'eos': (GObject.SignalFlags.RUN_FIRST, None, ()),
'clock-tick': (GObject.SignalFlags.RUN_FIRST, None, (int, )) 'clock-tick': (GObject.SignalFlags.RUN_FIRST, None, (int, )),
'seek-finished': (GObject.SignalFlags.RUN_FIRST, None, ())
} }
def __repr__(self): def __repr__(self):
...@@ -86,6 +87,7 @@ class GstPlayer(GObject.GObject): ...@@ -86,6 +87,7 @@ class GstPlayer(GObject.GObject):
self._bus.connect('message::async-done', self._on_async_done) self._bus.connect('message::async-done', self._on_async_done)
self._bus.connect('message::error', self._on_bus_error) self._bus.connect('message::error', self._on_bus_error)
self._bus.connect('message::element', self._on_bus_element) 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::eos', self._on_bus_eos)
self._bus.connect('message::new-clock', self._on_new_clock) self._bus.connect('message::new-clock', self._on_new_clock)
...@@ -135,6 +137,10 @@ class GstPlayer(GObject.GObject): ...@@ -135,6 +137,10 @@ class GstPlayer(GObject.GObject):
self.notify('state') self.notify('state')
@log
def _on_reset_time(self, bus, message):
self.emit("seek-finished")
@log @log
def _on_new_clock(self, bus, message): def _on_new_clock(self, bus, message):
clock = message.parse_new_clock() clock = message.parse_new_clock()
...@@ -275,7 +281,6 @@ class GstPlayer(GObject.GObject): ...@@ -275,7 +281,6 @@ class GstPlayer(GObject.GObject):
:param float seconds: Position in seconds to seek :param float seconds: Position in seconds to seek
""" """
# FIXME: seek should be signalled to MPRIS
self._player.seek_simple( self._player.seek_simple(
Gst.Format.TIME, Gst.SeekFlags.FLUSH | Gst.SeekFlags.KEY_UNIT, Gst.Format.TIME, Gst.SeekFlags.FLUSH | Gst.SeekFlags.KEY_UNIT,
seconds * Gst.SECOND) seconds * Gst.SECOND)
......
...@@ -579,6 +579,7 @@ class Player(GObject.GObject): ...@@ -579,6 +579,7 @@ class Player(GObject.GObject):
self._gst_player = GstPlayer(application) self._gst_player = GstPlayer(application)
self._gst_player.connect('clock-tick', self._on_clock_tick) self._gst_player.connect('clock-tick', self._on_clock_tick)
self._gst_player.connect('eos', self._on_eos) self._gst_player.connect('eos', self._on_eos)
self._gst_player.connect('seek-finished', self._on_seek_finished)
self._gst_player.bind_property( self._gst_player.bind_property(
'duration', self, 'duration', GObject.BindingFlags.SYNC_CREATE) 'duration', self, 'duration', GObject.BindingFlags.SYNC_CREATE)
self._gst_player.bind_property( self._gst_player.bind_property(
...@@ -878,7 +879,6 @@ class Player(GObject.GObject): ...@@ -878,7 +879,6 @@ class Player(GObject.GObject):
duration_second = self._gst_player.props.duration duration_second = self._gst_player.props.duration
if position_second <= duration_second: if position_second <= duration_second:
self._gst_player.seek(position_second) self._gst_player.seek(position_second)
self.emit('seek-finished')
@log @log
def get_mpris_playlist(self): def get_mpris_playlist(self):
...@@ -892,3 +892,8 @@ class Player(GObject.GObject): ...@@ -892,3 +892,8 @@ class Player(GObject.GObject):
:rtype: list of index and Grl.Media :rtype: list of index and Grl.Media
""" """
return self._playlist.get_mpris_playlist() return self._playlist.get_mpris_playlist()
@log
def _on_seek_finished(self, klass):
# FIXME: Just a proxy
self.emit('seek-finished')
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