[gnome-music/wip/jfelder/restore-mpris-playlists: 1/9] playlistsview: Start playing once the model is loaded



commit afbffcb3251abe15033cc2d0a28e4d76357e289e
Author: Jean Felder <jfelder src gnome org>
Date:   Tue Sep 17 17:12:48 2019 +0200

    playlistsview: Start playing once the model is loaded

 gnomemusic/views/playlistsview.py | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
---
diff --git a/gnomemusic/views/playlistsview.py b/gnomemusic/views/playlistsview.py
index b7ab67c9..d96a7591 100644
--- a/gnomemusic/views/playlistsview.py
+++ b/gnomemusic/views/playlistsview.py
@@ -274,11 +274,18 @@ class PlaylistsView(BaseView):
         if widget is not None:
             coresong = widget.props.coresong
 
+        signal_id = None
+
+        def _on_playlist_loaded(klass):
+            self._player.play(coresong)
+            self._coremodel.disconnect(signal_id)
+
         selection = self._sidebar.get_selected_row()
         current_playlist = selection.props.playlist
+        signal_id = self._coremodel.connect(
+            "playlist-loaded", _on_playlist_loaded)
         self._coremodel.set_player_model(
             PlayerPlaylist.Type.PLAYLIST, current_playlist.props.model)
-        self._player.play(coresong)
 
         return True
 


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