[gnome-music/wip/jfelder/mpris-handle-tracklist-changes: 1/3] mpris: Listen to the changes on the player playlist
- From: Jean Felder <jfelder src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/jfelder/mpris-handle-tracklist-changes: 1/3] mpris: Listen to the changes on the player playlist
- Date: Sun, 3 Nov 2019 22:19:54 +0000 (UTC)
commit ffebffde48c552d3a93a773412ab78d4c4efdd10
Author: Jean Felder <jfelder src gnome org>
Date: Sun Nov 3 16:23:42 2019 +0100
mpris: Listen to the changes on the player playlist
When the player playlist changes (some songs are added or removed),
the MPRIS tracklist needs to be updated (handled by update_songs_list)
and some of the MPRIS player properties need to be checked (CanPlay,
CanPause, CanGoNext and CanGoPrevious). If these properties are
changed, a PropertiesChanged signal needs to be emitted with the
changed properties.
The same operation is performed when the current song changes. So both
operations can call the same new function: _on_player_model_changed.
related: #336
gnomemusic/mpris.py | 5 +++++
1 file changed, 5 insertions(+)
---
diff --git a/gnomemusic/mpris.py b/gnomemusic/mpris.py
index 89719dbd..1d33bd46 100644
--- a/gnomemusic/mpris.py
+++ b/gnomemusic/mpris.py
@@ -293,6 +293,8 @@ class MPRIS(DBusInterface):
self._coremodel = app.props.coremodel
self._player_model = self._coremodel.props.playlist_sort
+ self._player_model.connect(
+ "items-changed", self._on_player_model_changed)
self._coremodel.connect(
"playlist-loaded", self._on_player_playlist_changed)
@@ -515,6 +517,9 @@ class MPRIS(DBusInterface):
if self._previous_can_play is True:
return
+ self._on_player_model_changed(None, 0, 0, 0)
+
+ def _on_player_model_changed(self, model, pos, removed, added):
self._update_songs_list()
properties = {}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]