[gnome-music/wip/mschraal/player-gapless-prev-next] player: Fix previous/next on gapless playback



commit e76f628cf1bc1ed474e962d4a91c3a903b0c876a
Author: Marinus Schraal <mschraal gnome org>
Date:   Thu Mar 26 08:57:57 2020 +0100

    player: Fix previous/next on gapless playback
    
    When the about-to-finish signal is received in Player, GstPlayer is
    prepared to play the next song in gapless mode. The previous() and
    next() calls in Player did not take into account this special case,
    resulting in an unresponsive Player.
    
    To fix this issue, next() now seeks to the start of the new stream.
    previous() does a start/stop cycle with the current song, as the new uri
    is already set and cannot be reverted.
    
    Closes: #375

 gnomemusic/player.py | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)
---
diff --git a/gnomemusic/player.py b/gnomemusic/player.py
index 7104fcac..94d84b63 100644
--- a/gnomemusic/player.py
+++ b/gnomemusic/player.py
@@ -493,7 +493,9 @@ class Player(GObject.GObject):
 
         Play the next song of the playlist, if any.
         """
-        if self._playlist.next():
+        if self._gapless_set:
+            self.set_position(0.0)
+        elif self._playlist.next():
             self.play(self._playlist.props.current_song)
 
     def previous(self):
@@ -502,12 +504,16 @@ class Player(GObject.GObject):
         Play the previous song of the playlist, if any.
         """
         position = self._gst_player.props.position
-        if position >= 5:
-            self.set_position(0.0)
-            return
+        if self._gapless_set:
+            self.stop()
 
-        if self._playlist.previous():
+        if (position < 5
+                and self._playlist.previous()):
+            self.play(self._playlist.props.current_song)
+        elif self._gapless_set:
             self.play(self._playlist.props.current_song)
+        else:
+            self.set_position(0.0)
 
     def play_pause(self):
         """Toggle play/pause state"""


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