Implemented shuffle mode properl

This commit is contained in:
Manuel Cortez 2018-01-26 12:03:07 -06:00
parent a91e081aa0
commit 00a1560b60
2 changed files with 10 additions and 1 deletions

View File

@ -36,7 +36,11 @@ class Controller(object):
results = _("Showing {0} results.").format(len(self.results))
else:
results = ""
final = results+" "
if player.player.shuffle:
shuffle = _("Shuffle on")
else:
shuffle = ""
final = "{0} {1}".format(results, shuffle)
return final
def connect_events(self):
@ -51,6 +55,7 @@ class Controller(object):
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.on_volume_down, menuitem=self.window.player_volume_down)
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.on_volume_up, menuitem=self.window.player_volume_up)
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.on_mute, menuitem=self.window.player_mute)
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.on_shuffle, menuitem=self.window.player_shuffle)
pub.subscribe(self.change_status, "change_status")
# Event functions. These functions will call other functions in a thread and are bound to widget events.
@ -98,6 +103,9 @@ class Controller(object):
def on_mute(self, *args, **kwargs):
player.player.volume = 0
def on_shuffle(self, *args, **kwargs):
player.player.shuffle = self.window.player_shuffle.IsChecked()
def change_status(self, status):
""" Function used for changing the status bar from outside the main controller module."""
self.window.change_status("{0} {1}".format(status, self.get_status_info()))

View File

@ -27,6 +27,7 @@ class audioPlayer(object):
self.queue = []
self.stopped = True
self.queue_pos = 0
self.shuffle = False
def play(self, item):
if self.stream != None and self.stream.is_playing == True: