[gnome-music/wip/mschraal/core-gapless: 2/2] try 1
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/mschraal/core-gapless: 2/2] try 1
- Date: Thu, 8 Aug 2019 15:24:18 +0000 (UTC)
commit 60b8f00c103b58bdf7b5e23f2a0344f663e9e1c7
Author: Marinus Schraal <mschraal gnome org>
Date: Thu Aug 8 12:53:54 2019 +0200
try 1
gnomemusic/player.py | 30 ++++++++++++++++++++++++++----
1 file changed, 26 insertions(+), 4 deletions(-)
---
diff --git a/gnomemusic/player.py b/gnomemusic/player.py
index 2dc2e127..c8af99f6 100644
--- a/gnomemusic/player.py
+++ b/gnomemusic/player.py
@@ -126,6 +126,20 @@ class PlayerPlaylist(GObject.GObject):
return False
+ def get_next(self):
+ if not self.has_next():
+ return None
+
+ if self.props.repeat_mode == RepeatMode.SONG:
+ next_position = self.props.position
+ elif (self.props.repeat_mode == RepeatMode.ALL
+ and self.props.position == self._model.get_n_items() - 1):
+ next_position = 0
+ else:
+ next_position = self.props.position + 1
+
+ return self._model[next_position]
+
@log
def next(self):
"""Go to the next song in the playlist.
@@ -439,26 +453,31 @@ class Player(GObject.GObject):
@log
def _on_about_to_finish(self, klass):
+ print("gapless")
if self.props.has_next:
- self._playlist.next()
-
- new_url = self._playlist.props.current_song.props.url
+ next_coresong = self._playlist.get_next()
+ new_url = next_coresong.props.url
+ # new_url = self._playlist.props.current_song.props.url
self._gst_player.props.url = new_url
self._gapless_set = True
@log
def _on_eos(self, klass):
+ print("eos", self._gapless_set)
+ self._playlist.next()
+
if self._gapless_set:
# After 'eos' in the gapless case, the pipeline needs to be
# hard reset.
self.stop()
- self.play()
+ self.play(self.props.current_song)
else:
self.stop()
self._gapless_set = False
def _on_error(self, klass=None):
+ print("error")
self.stop()
self._gapless_set = False
@@ -469,6 +488,9 @@ class Player(GObject.GObject):
self.next()
def _on_stream_start(self, klass):
+ if self._gapless_set:
+ self._playlist.next()
+
self._gapless_set = False
self._time_stamp = int(time.time())
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]