[gnome-music/wip/jfelder/mpris-fix-seek: 3/3] player: Fix seek signal emission
- From: Jean Felder <jfelder src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/jfelder/mpris-fix-seek: 3/3] player: Fix seek signal emission
- Date: Thu, 18 Oct 2018 10:55:27 +0000 (UTC)
commit 900f95ed57cd84ec17f4ec0cef8225711fc5a694
Author: Jean Felder <jfelder src gnome org>
Date: Thu Oct 18 12:07:32 2018 +0200
player: Fix seek signal emission
Seek operations synchronization between SmoothScale and MPRIS has
never worked reliably.
With the previous changes, it is now possible to correctly emit a
seek-finished signal once a seek operation has been requested by
SmoothScale. MPRIS listens to this signal to emit its own seeked
signal.
gnomemusic/gstplayer.py | 1 -
gnomemusic/mpris.py | 4 ++--
gnomemusic/player.py | 5 +++--
3 files changed, 5 insertions(+), 5 deletions(-)
---
diff --git a/gnomemusic/gstplayer.py b/gnomemusic/gstplayer.py
index b4648163..0cbab0fb 100644
--- a/gnomemusic/gstplayer.py
+++ b/gnomemusic/gstplayer.py
@@ -261,7 +261,6 @@ class GstPlayer(GObject.GObject):
:rtype: float
"""
position = self._player.query_position(Gst.Format.TIME)[1] / Gst.SECOND
-
return position
@GObject.Property(type=float)
diff --git a/gnomemusic/mpris.py b/gnomemusic/mpris.py
index 969c373d..c46961e3 100644
--- a/gnomemusic/mpris.py
+++ b/gnomemusic/mpris.py
@@ -228,7 +228,7 @@ class MediaPlayer2Service(Server):
self.player.connect('notify::repeat-mode', self._on_repeat_mode_changed)
self.player.connect('volume-changed', self._on_volume_changed)
self.player.connect('prev-next-invalidated', self._on_prev_next_invalidated)
- self.player.connect('seeked', self._on_seeked)
+ self.player.connect('seek-finished', self._on_seek_finished)
self.player.connect('playlist-changed', self._on_playlist_changed)
self.player_toolbar = app.get_active_window()._player_toolbar
self.player_toolbar.connect(
@@ -471,7 +471,7 @@ class MediaPlayer2Service(Server):
self.player.play()
@log
- def _on_seeked(self, player, position_second):
+ def _on_seek_finished(self, player, position_second):
self.Seeked(int(position_second * 1e6))
@log
diff --git a/gnomemusic/player.py b/gnomemusic/player.py
index 8991eecf..ce41c735 100644
--- a/gnomemusic/player.py
+++ b/gnomemusic/player.py
@@ -499,7 +499,7 @@ class Player(GObject.GObject):
'clock-tick': (GObject.SignalFlags.RUN_FIRST, None, (int,)),
'playlist-changed': (GObject.SignalFlags.RUN_FIRST, None, ()),
'prev-next-invalidated': (GObject.SignalFlags.RUN_FIRST, None, ()),
- 'seeked': (GObject.SignalFlags.RUN_FIRST, None, (int,)),
+ 'seek-finished': (GObject.SignalFlags.RUN_FIRST, None, (float,)),
'song-changed': (GObject.SignalFlags.RUN_FIRST, None, (int,)),
'song-validated': (GObject.SignalFlags.RUN_FIRST, None, (int, int)),
'volume-changed': (GObject.SignalFlags.RUN_FIRST, None, ()),
@@ -636,7 +636,7 @@ class Player(GObject.GObject):
"""
position = self._player.position
if position >= 5:
- self._player.seek(0)
+ self.set_position(0.0)
return
if self._playlist.previous():
@@ -826,6 +826,7 @@ class Player(GObject.GObject):
duration_second = self._player.props.duration
if position_second <= duration_second:
self._player.seek(position_second)
+ self.emit('seek-finished', position_second)
@log
def get_volume(self):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]