From e6eaa8655ebfd339d0e330499a2945c42101a588 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20Cort=C3=A9z?= Date: Mon, 15 Feb 2016 17:49:39 -0600 Subject: [PATCH] Play button in the audio details dialogue now works --- src/controller/buffers.py | 5 ++--- src/controller/mainController.py | 8 +++++++- src/controller/posts.py | 6 +++++- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/controller/buffers.py b/src/controller/buffers.py index 576bc89..ce989ca 100644 --- a/src/controller/buffers.py +++ b/src/controller/buffers.py @@ -2,9 +2,9 @@ import wx import widgetUtils import messages -import player import utils import posts +import player from wxUI.tabs import home from pubsub import pub from sessionmanager import session @@ -101,11 +101,10 @@ class audioBuffer(feedBuffer): def play_audio(self, *args, **kwargs): selected = self.tab.list.get_selected() - call_threaded(player.player.play, self.session.db[self.name]["items"][selected]["url"]) + pub.sendMessage("play-audio", audio_object=self.session.db[self.name]["items"][selected]["url"]) def open_post(self): selected = self.tab.list.get_selected() a = posts.audio(self.session, self.session.db[self.name]["items"][selected]) a.dialog.get_response() -player.setup() \ No newline at end of file diff --git a/src/controller/mainController.py b/src/controller/mainController.py index 6e2906a..743f8d5 100644 --- a/src/controller/mainController.py +++ b/src/controller/mainController.py @@ -3,6 +3,7 @@ import utils import widgetUtils import messages import buffers +import player from pubsub import pub from mysc.repeating_timer import RepeatingTimer from mysc.thread_utils import call_threaded @@ -20,6 +21,7 @@ class Controller(object): def __init__(self): super(Controller, self).__init__() self.buffers = [] + player.setup() self.window = mainWindow.mainWindow() self.window.change_status(_(u"Ready")) self.session = session.sessions[session.sessions.keys()[0]] @@ -42,6 +44,7 @@ class Controller(object): self.window.add_buffer(audio.tab, _(u"My audios")) pub.subscribe(self.in_post, "posted") pub.subscribe(self.download, "download-file") + pub.subscribe(self.play_audio, "play-audio") def login(self): self.window.change_status(_(u"Logging in VK")) @@ -66,4 +69,7 @@ class Controller(object): print "executed for %s" % (i.name) def download(self, url, filename): - call_threaded(utils.download_file, url, filename, self.window) \ No newline at end of file + call_threaded(utils.download_file, url, filename, self.window) + + def play_audio(self, audio_object): + call_threaded(player.player.play, audio_object) diff --git a/src/controller/posts.py b/src/controller/posts.py index 37a2410..cf82d4f 100644 --- a/src/controller/posts.py +++ b/src/controller/posts.py @@ -195,6 +195,7 @@ class audio(postController): self.dialog = postDialogs.audio() self.fill_information() widgetUtils.connect_event(self.dialog.download, widgetUtils.BUTTON_PRESSED, self.download) + widgetUtils.connect_event(self.dialog.play, widgetUtils.BUTTON_PRESSED, self.play) def fill_information(self): if self.post.has_key("artist"): @@ -215,4 +216,7 @@ class audio(postController): f = u"{0} - {1}.mp3".format(self.post["title"], self.post["artist"]) path = self.dialog.get_destination_path(f) if path != None: - pub.sendMessage("download-file", url=self.post["url"], filename=f) \ No newline at end of file + pub.sendMessage("download-file", url=self.post["url"], filename=f) + + def play(self, *args, **kwargs): + pub.sendMessage("play-audio", audio_object=self.post["url"])