[gnome-music/wip/jfelder/mpris-seek: 4/4] mpris: Limit Seeked signal emissions
- From: Jean Felder <jfelder src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/jfelder/mpris-seek: 4/4] mpris: Limit Seeked signal emissions
- Date: Tue, 16 Apr 2019 20:26:02 +0000 (UTC)
commit 8d56e7f8624f63ec4edbfbda71f13cc32496cb48
Author: Jean Felder <jfelder src gnome org>
Date: Tue Apr 16 16:15:53 2019 +0200
mpris: Limit Seeked signal emissions
Related: #43
gnomemusic/mpris.py | 8 ++++++++
1 file changed, 8 insertions(+)
---
diff --git a/gnomemusic/mpris.py b/gnomemusic/mpris.py
index ccc7c89a..f98265fb 100644
--- a/gnomemusic/mpris.py
+++ b/gnomemusic/mpris.py
@@ -240,6 +240,7 @@ class MediaPlayer2Service(Server):
self._path_list = []
self._metadata_list = []
self._previous_playback_status = "Stopped"
+ self._song_position = 0
@log
def _get_playback_status(self):
@@ -609,6 +610,13 @@ class MediaPlayer2Service(Server):
:param int position_msecond: new position in microseconds.
"""
+ # Only send the signal when the position has changed in a way
+ # that is inconsistant with the current playing state
+ if abs(position_msecond - self._song_position) < 2e6:
+ self._song_position = position_msecond
+ return
+
+ self._song_position = position_msecond
variant = GLib.Variant.new_tuple(GLib.Variant('x', position_msecond))
self.con.emit_signal(
None, '/org/mpris/MediaPlayer2',
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]