Started pubsub implementation in all player related functions

This commit is contained in:
Manuel Cortez 2019-04-10 17:49:23 -05:00
parent 6d6daa60b6
commit 9cb1f9647c
2 changed files with 8 additions and 2 deletions

View File

@ -340,13 +340,13 @@ class Controller(object):
if "url" in audio_object and audio_object["url"] =="": if "url" in audio_object and audio_object["url"] =="":
self.notify(message=_("This file could not be played because it is not allowed in your country")) self.notify(message=_("This file could not be played because it is not allowed in your country"))
return return
call_threaded(player.player.play, audio_object, fresh=True) pub.sendMessage("play", object=audio_object, fresh=True)
def play_audios(self, audios): def play_audios(self, audios):
""" Play all audios passed in alist, putting the audio in a queue of the media player. """ Play all audios passed in alist, putting the audio in a queue of the media player.
@audios list: A list of Vk audio objects. @audios list: A list of Vk audio objects.
""" """
player.player.play_all(audios, shuffle=self.window.player_shuffle.IsChecked()) pub.sendMessage("play_all", list_of_songs=audios, shuffle=self.window.player_shuffle.IsChecked())
def view_post(self, post_object, controller_): def view_post(self, post_object, controller_):
""" Display the passed post in the passed post presenter. """ Display the passed post in the passed post presenter.

View File

@ -45,6 +45,12 @@ class audioPlayer(object):
bassconfig = BassConfig() bassconfig = BassConfig()
# Set timeout connection to 30 seconds. # Set timeout connection to 30 seconds.
bassconfig["net_timeout"] = 30000 bassconfig["net_timeout"] = 30000
pub.subscribe(self.play, "play")
pub.subscribe(self.play_all, "play_all")
pub.subscribe(self.pause, "pause")
pub.subscribe(self.stop, "stop")
pub.subscribe(self.play_next, "play_next")
pub.subscribe(self.play_previous, "play_previous")
def play(self, object, set_info=True, fresh=False): def play(self, object, set_info=True, fresh=False):
""" Play an URl Stream. """ Play an URl Stream.