Commit b72c4c10 authored by Jean Felder's avatar Jean Felder

mpris: Correctly listen to player model changes

This is a follow up and fix of commit

The MPRIS tracklist (and some other properties) need to be updated in
two cases:
- the current song changes
- the player playlist changes (some songs are added or removed)

Commit a65f4439 added the possibility
to handle the latter case.

However, when a new player playlist is loaded (the user clicks on an
other album or artist for example), the player playlist is completely
refreshed. In that corner case, the MPRIS tracklist cannot be updated
because the player position has not been updated yet. The MPRIS
tracklist (and the other properties) will be correctly updated once a
new song is playing (by the _on_current_song_changed method).
parent 85480eed
......@@ -521,9 +521,14 @@ class MPRIS(DBusInterface):
self._player_model_changed_id = self._player_model.connect_after(
"items-changed", self._on_player_model_changed)
self._on_player_model_changed(None, 0, 0, 0)
self._on_player_model_changed(self._player_model, 0, 0, 0)
def _on_player_model_changed(self, model, pos, removed, added):
# Do no update the properties if the model has completely changed.
# These changes will be applied once a new song starts playing.
if added == model.get_n_items():
properties = {}
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