[gnome-music] Add support shuffle history
- From: Vadim Rutkovsky <vrutkovsky src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music] Add support shuffle history
- Date: Thu, 27 Feb 2014 11:16:55 +0000 (UTC)
commit c31847e2e7c06e9ca3f20a6c604c39549e6ce01f
Author: Anton Belka <antonbelka gmail com>
Date: Thu Feb 27 14:10:31 2014 +0300
Add support shuffle history
gnomemusic/player.py | 10 +++++++++-
1 files changed, 9 insertions(+), 1 deletions(-)
---
diff --git a/gnomemusic/player.py b/gnomemusic/player.py
index 788929e..c153c27 100644
--- a/gnomemusic/player.py
+++ b/gnomemusic/player.py
@@ -35,6 +35,7 @@ GIRepository.Repository.prepend_search_path('libgd')
from gi.repository import Gtk, Gdk, GLib, Gio, GObject, Gst, GstAudio, GstPbutils
from gettext import gettext as _
from random import randint
+from queue import LifoQueue
from gnomemusic.albumArtCache import AlbumArtCache
ART_SIZE = 34
@@ -56,6 +57,7 @@ class PlaybackStatus:
class Player(GObject.GObject):
nextTrack = None
timeout = None
+ shuffleHistory = LifoQueue(maxsize=10)
__gsignals__ = {
'playing-changed': (GObject.SIGNAL_RUN_FIRST, None, ()),
@@ -225,6 +227,9 @@ class Player(GObject.GObject):
elif self.repeat == RepeatType.SHUFFLE:
if currentTrack:
nextTrack = self._get_random_iter(currentTrack)
+ if self.shuffleHistory.full():
+ self.shuffleHistory.get_nowait()
+ self.shuffleHistory.put_nowait(currentTrack)
if nextTrack:
return Gtk.TreeRowReference.new(self.playlist, self.playlist.get_path(nextTrack))
@@ -264,7 +269,10 @@ class Player(GObject.GObject):
previousTrack = self.playlist.iter_previous(currentTrack)
elif self.repeat == RepeatType.SHUFFLE:
if currentTrack:
- previousTrack = self._get_random_iter(currentTrack)
+ if not self.shuffleHistory.empty():
+ previousTrack = self.shuffleHistory.get_nowait()
+ else:
+ previousTrack = self._get_random_iter(currentTrack)
if previousTrack:
return Gtk.TreeRowReference.new(self.playlist, self.playlist.get_path(previousTrack))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]