Play button in the audio details dialogue now works

This commit is contained in:
Manuel Cortez 2016-02-15 17:49:39 -06:00
parent b30ad96895
commit e6eaa8655e
3 changed files with 14 additions and 5 deletions

View File

@ -2,9 +2,9 @@
import wx import wx
import widgetUtils import widgetUtils
import messages import messages
import player
import utils import utils
import posts import posts
import player
from wxUI.tabs import home from wxUI.tabs import home
from pubsub import pub from pubsub import pub
from sessionmanager import session from sessionmanager import session
@ -101,11 +101,10 @@ class audioBuffer(feedBuffer):
def play_audio(self, *args, **kwargs): def play_audio(self, *args, **kwargs):
selected = self.tab.list.get_selected() 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): def open_post(self):
selected = self.tab.list.get_selected() selected = self.tab.list.get_selected()
a = posts.audio(self.session, self.session.db[self.name]["items"][selected]) a = posts.audio(self.session, self.session.db[self.name]["items"][selected])
a.dialog.get_response() a.dialog.get_response()
player.setup()

View File

@ -3,6 +3,7 @@ import utils
import widgetUtils import widgetUtils
import messages import messages
import buffers import buffers
import player
from pubsub import pub from pubsub import pub
from mysc.repeating_timer import RepeatingTimer from mysc.repeating_timer import RepeatingTimer
from mysc.thread_utils import call_threaded from mysc.thread_utils import call_threaded
@ -20,6 +21,7 @@ class Controller(object):
def __init__(self): def __init__(self):
super(Controller, self).__init__() super(Controller, self).__init__()
self.buffers = [] self.buffers = []
player.setup()
self.window = mainWindow.mainWindow() self.window = mainWindow.mainWindow()
self.window.change_status(_(u"Ready")) self.window.change_status(_(u"Ready"))
self.session = session.sessions[session.sessions.keys()[0]] self.session = session.sessions[session.sessions.keys()[0]]
@ -42,6 +44,7 @@ class Controller(object):
self.window.add_buffer(audio.tab, _(u"My audios")) self.window.add_buffer(audio.tab, _(u"My audios"))
pub.subscribe(self.in_post, "posted") pub.subscribe(self.in_post, "posted")
pub.subscribe(self.download, "download-file") pub.subscribe(self.download, "download-file")
pub.subscribe(self.play_audio, "play-audio")
def login(self): def login(self):
self.window.change_status(_(u"Logging in VK")) self.window.change_status(_(u"Logging in VK"))
@ -66,4 +69,7 @@ class Controller(object):
print "executed for %s" % (i.name) print "executed for %s" % (i.name)
def download(self, url, filename): def download(self, url, filename):
call_threaded(utils.download_file, url, filename, self.window) call_threaded(utils.download_file, url, filename, self.window)
def play_audio(self, audio_object):
call_threaded(player.player.play, audio_object)

View File

@ -195,6 +195,7 @@ class audio(postController):
self.dialog = postDialogs.audio() self.dialog = postDialogs.audio()
self.fill_information() self.fill_information()
widgetUtils.connect_event(self.dialog.download, widgetUtils.BUTTON_PRESSED, self.download) 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): def fill_information(self):
if self.post.has_key("artist"): 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"]) f = u"{0} - {1}.mp3".format(self.post["title"], self.post["artist"])
path = self.dialog.get_destination_path(f) path = self.dialog.get_destination_path(f)
if path != None: if path != None:
pub.sendMessage("download-file", url=self.post["url"], filename=f) pub.sendMessage("download-file", url=self.post["url"], filename=f)
def play(self, *args, **kwargs):
pub.sendMessage("play-audio", audio_object=self.post["url"])