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 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()

View File

@ -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)
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.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)
pub.sendMessage("download-file", url=self.post["url"], filename=f)
def play(self, *args, **kwargs):
pub.sendMessage("play-audio", audio_object=self.post["url"])