[gnome-music/wip/mschraal/core] player: Speed up current_song



commit 16abf1bea0bec6f9b76451e960b85ccf691cacb6
Author: Marinus Schraal <mschraal gnome org>
Date:   Wed Jun 5 12:00:21 2019 +0200

    player: Speed up current_song

 gnomemusic/player.py | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
---
diff --git a/gnomemusic/player.py b/gnomemusic/player.py
index 6c5b9704..e922ca2b 100644
--- a/gnomemusic/player.py
+++ b/gnomemusic/player.py
@@ -441,8 +441,15 @@ class PlayerPlaylist(GObject.GObject):
         :returns: the song being played or None if there are no songs
         :rtype: Grl.Media
         """
-        for coresong in self._model:
+        if self._model.get_n_items() != 0:
+            current_song = self._model[self._current_index]
+            if current_song.props.state == SongWidget.State.PLAYING:
+                return current_song.props.media
+
+        for idx, coresong in enumerate(self._model):
             if coresong.props.state == SongWidget.State.PLAYING:
+                print("position", idx)
+                self._current_index = idx
                 return coresong.props.media
 
         return None


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