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



commit 7ea53306abd251a846a8b92c9bb133fdd3256341
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 3629ee4c..0f445d41 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]