[gnome-music/wip/mschraal/core] player: Simplify play



commit 0424f34540e9d9d60dd556a44931c4d60f9f57eb
Author: Marinus Schraal <mschraal gnome org>
Date:   Wed Jul 3 22:35:50 2019 +0200

    player: Simplify play
    
    Drops offset, look to bring it back later.

 gnomemusic/mpris.py                      |  3 ++-
 gnomemusic/player.py                     | 18 +++---------------
 gnomemusic/widgets/albumwidget.py        |  3 +--
 gnomemusic/widgets/artistalbumswidget.py |  2 +-
 4 files changed, 7 insertions(+), 19 deletions(-)
---
diff --git a/gnomemusic/mpris.py b/gnomemusic/mpris.py
index 8e90ad54..f2bb71bf 100644
--- a/gnomemusic/mpris.py
+++ b/gnomemusic/mpris.py
@@ -722,7 +722,8 @@ class MPRIS(DBusInterface):
         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)
+        # FIXME: Dropped this for core rewrite.
+        # self._player.play(song_offset=song_offset)
 
     def _track_list_replaced(self, tracks, current_song):
         parameters = {
diff --git a/gnomemusic/player.py b/gnomemusic/player.py
index 6055e092..165ac3d2 100644
--- a/gnomemusic/player.py
+++ b/gnomemusic/player.py
@@ -492,14 +492,13 @@ class Player(GObject.GObject):
         self._gst_player.props.url = coresong.props.url
 
     @log
-    def play(self, song_changed=True, song_offset=None, coresong=None):
+    def play(self, coresong=None):
         """Play a song.
 
         Load a new song or resume playback depending on song_changed
         value. If song_offset is defined, set a new song and play it.
 
         :param bool song_changed: indicate if a new song must be loaded
-        :param int song_offset: position relative to current song
         """
         if self.props.current_song is None:
             return
@@ -510,17 +509,6 @@ class Player(GObject.GObject):
         self._load(coresong)
 
         self._gst_player.props.state = Playback.PLAYING
-        return
-
-        if (song_offset is not None
-                and not self._playlist.set_song(song_offset)):
-            return False
-
-        if (song_changed
-                or self._gapless_set):
-            self._load(self._playlist.props.current_song)
-
-        self._gst_player.props.state = Playback.PLAYING
 
     @log
     def pause(self):
@@ -539,7 +527,7 @@ class Player(GObject.GObject):
         Play the next song of the playlist, if any.
         """
         if self._playlist.next():
-            self.play(None, None, self._playlist.props.current_song)
+            self.play(self._playlist.props.current_song)
 
     @log
     def previous(self):
@@ -561,7 +549,7 @@ class Player(GObject.GObject):
         if self.props.state == Playback.PLAYING:
             self.pause()
         else:
-            self.play(False)
+            self.play()
 
     @log
     def set_playlist(self, playlist_type, playlist_id, model, iter_=None):
diff --git a/gnomemusic/widgets/albumwidget.py b/gnomemusic/widgets/albumwidget.py
index 8e9172a7..6e682cc0 100644
--- a/gnomemusic/widgets/albumwidget.py
+++ b/gnomemusic/widgets/albumwidget.py
@@ -155,7 +155,6 @@ class AlbumWidget(Gtk.EventBox):
 
     @log
     def _song_activated(self, widget, song_widget):
-        print("activated", song_widget)
         if self.props.selection_mode:
             song_widget.props.selected = not song_widget.props.selected
             return
@@ -164,7 +163,7 @@ class AlbumWidget(Gtk.EventBox):
         coremodel = self._parent_view._window._app.props.coremodel
 
         def _on_playlist_loaded(klass):
-            self._player.play(None, None, song_widget.props.coresong)
+            self._player.play(song_widget.props.coresong)
             coremodel.disconnect(signal_id)
 
         signal_id = coremodel.connect("playlist-loaded", _on_playlist_loaded)
diff --git a/gnomemusic/widgets/artistalbumswidget.py b/gnomemusic/widgets/artistalbumswidget.py
index c87879ab..e9345d88 100644
--- a/gnomemusic/widgets/artistalbumswidget.py
+++ b/gnomemusic/widgets/artistalbumswidget.py
@@ -107,7 +107,7 @@ class ArtistAlbumsWidget(Gtk.Box):
         coremodel = self._player._app.props.coremodel
 
         def _on_playlist_loaded(klass):
-            self._player.play(None, None, song_widget.props.coresong)
+            self._player.play(song_widget.props.coresong)
             coremodel.disconnect(signal_id)
 
         signal_id = coremodel.connect("playlist-loaded", _on_playlist_loaded)


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