[gnome-music/wip/jfelder/mpris-cleanup: 18/28] mpris: Do not send PlaybackStatus property if unchanged
- From: Jean Felder <jfelder src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/jfelder/mpris-cleanup: 18/28] mpris: Do not send PlaybackStatus property if unchanged
- Date: Wed, 20 Mar 2019 17:00:30 +0000 (UTC)
commit 713f31896a16e610a9ebe4ab9c0ac5e34a4174e6
Author: Jean Felder <jfelder src gnome org>
Date: Wed Mar 20 11:27:09 2019 +0100
mpris: Do not send PlaybackStatus property if unchanged
GstPlayer state changes can be redundant because of its asynchronous
nature. For example, when launching a new song, the playing state is
sent two times. This results in the PlaybackStatus "Playing" property
being sent two times.
Checking that the status has really changed to avoid sending two
times the same signal.
Related: #43
gnomemusic/mpris.py | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
---
diff --git a/gnomemusic/mpris.py b/gnomemusic/mpris.py
index 27e29a9e..e2c07237 100644
--- a/gnomemusic/mpris.py
+++ b/gnomemusic/mpris.py
@@ -271,6 +271,7 @@ class MPRIS(DBusInterface):
self._player_previous_type = None
self._path_list = []
self._metadata_list = []
+ self._previous_playback_status = "Stopped"
@log
def _get_playback_status(self):
@@ -465,9 +466,14 @@ class MPRIS(DBusInterface):
@log
def _on_player_state_changed(self, klass, args):
+ playback_status = self._get_playback_status()
+ if playback_status == self._previous_playback_status:
+ return
+
+ self._previous_playback_status = playback_status
self.PropertiesChanged(MPRIS.MEDIA_PLAYER2_PLAYER_IFACE,
{
- 'PlaybackStatus': GLib.Variant('s', self._get_playback_status()),
+ 'PlaybackStatus': GLib.Variant('s', playback_status),
},
[])
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]