[gnome-music/wip/jfelder/restore-mpris-playlists] mpris: Restore goto method



commit f214fd2a0291c8db0ddf5d203c6fc06f1b3d9c14
Author: Jean Felder <jfelder src gnome org>
Date:   Thu Sep 26 13:41:48 2019 +0200

    mpris: Restore goto method
    
    This functionality was disabled during the core rewrite.
    
    The usual way to play a song is to call set_player_model from
    CoreModel and then play method from the Player once the playlist is
    loaded. set_player_model allows to reset the state from the different
    CoreSong. The MPRIS interface does not have access to the current
    model, so set_player_model cannot be called. In that case, the
    coresong states need to be explicitly changed.

 gnomemusic/mpris.py | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)
---
diff --git a/gnomemusic/mpris.py b/gnomemusic/mpris.py
index ce0eac47..ff8f2e07 100644
--- a/gnomemusic/mpris.py
+++ b/gnomemusic/mpris.py
@@ -30,6 +30,7 @@ from gi.repository import Gio, GLib
 
 from gnomemusic import log
 from gnomemusic.albumartcache import lookup_art_file_from_cache
+from gnomemusic.widgets.songwidget import SongWidget
 from gnomemusic.gstplayer import Playback
 from gnomemusic.player import PlayerPlaylist, RepeatMode
 
@@ -739,13 +740,15 @@ class MPRIS(DBusInterface):
 
         :param str path: Identifier of the track to skip to
         """
-        # FIXME: Dropped this for core rewrite.
-        pass
-        # current_song_path = self._get_song_dbus_path()
-        # position = self._path_list.index(current_song_path)
-        # goto_index = self._path_list.index(path)
-        # song_offset = goto_index - position
-        # self._player.play(song_offset=song_offset)
+        current_index = self._path_list.index(self._get_song_dbus_path())
+        current_coresong = self._player_model[current_index]
+
+        goto_index = self._path_list.index(path)
+        new_coresong = self._player_model[goto_index]
+
+        self._player.play(new_coresong)
+        current_coresong.props.state = SongWidget.State.PLAYED
+        new_coresong.props.state = SongWidget.State.PLAYING
 
     def _track_list_replaced(self, tracks, current_song):
         parameters = {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]