Playing songs are shown in the status bar
This commit is contained in:
parent
586b1c2c42
commit
6a6db9e796
@ -101,7 +101,7 @@ class baseBuffer(object):
|
|||||||
def play_audio(self, *args, **kwargs):
|
def play_audio(self, *args, **kwargs):
|
||||||
post = self.session.db[self.name]["items"][self.tab.list.get_selected()]
|
post = self.session.db[self.name]["items"][self.tab.list.get_selected()]
|
||||||
if post.has_key("type") and post["type"] == "audio":
|
if post.has_key("type") and post["type"] == "audio":
|
||||||
pub.sendMessage("play-audio", audio_object=post["audio"][1]["url"])
|
pub.sendMessage("play-audio", audio_object=post["audio"]["items"][0])
|
||||||
|
|
||||||
def open_post(self):
|
def open_post(self):
|
||||||
post = self.session.db[self.name]["items"][self.tab.list.get_selected()]
|
post = self.session.db[self.name]["items"][self.tab.list.get_selected()]
|
||||||
@ -145,7 +145,7 @@ 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()
|
||||||
pub.sendMessage("play-audio", audio_object=self.session.db[self.name]["items"][selected]["url"])
|
pub.sendMessage("play-audio", audio_object=self.session.db[self.name]["items"][selected])
|
||||||
|
|
||||||
def open_post(self):
|
def open_post(self):
|
||||||
selected = self.tab.list.get_selected()
|
selected = self.tab.list.get_selected()
|
||||||
@ -158,7 +158,7 @@ class audioBuffer(feedBuffer):
|
|||||||
selected = self.tab.list.get_selected()
|
selected = self.tab.list.get_selected()
|
||||||
if selected == -1:
|
if selected == -1:
|
||||||
selected = 0
|
selected = 0
|
||||||
audios = [i["url"] for i in self.session.db[self.name]["items"][selected:]]
|
audios = [i for i in self.session.db[self.name]["items"][selected:]]
|
||||||
pub.sendMessage("play-audios", audios=audios)
|
pub.sendMessage("play-audios", audios=audios)
|
||||||
|
|
||||||
class empty(object):
|
class empty(object):
|
||||||
|
@ -72,6 +72,7 @@ class Controller(object):
|
|||||||
pub.subscribe(self.play_audio, "play-audio")
|
pub.subscribe(self.play_audio, "play-audio")
|
||||||
pub.subscribe(self.play_audios, "play-audios")
|
pub.subscribe(self.play_audios, "play-audios")
|
||||||
pub.subscribe(self.view_post, "open-post")
|
pub.subscribe(self.view_post, "open-post")
|
||||||
|
pub.subscribe(self.update_status_bar, "update-status-bar")
|
||||||
widgetUtils.connect_event(self.window, widgetUtils.CLOSE_EVENT, self.exit)
|
widgetUtils.connect_event(self.window, widgetUtils.CLOSE_EVENT, self.exit)
|
||||||
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.update_buffer, menuitem=self.window.update_buffer)
|
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.update_buffer, menuitem=self.window.update_buffer)
|
||||||
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.check_for_updates, menuitem=self.window.check_for_updates)
|
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.check_for_updates, menuitem=self.window.check_for_updates)
|
||||||
@ -84,6 +85,7 @@ class Controller(object):
|
|||||||
pub.unsubscribe(self.play_audio, "play-audio")
|
pub.unsubscribe(self.play_audio, "play-audio")
|
||||||
pub.unsubscribe(self.play_audios, "play-audios")
|
pub.unsubscribe(self.play_audios, "play-audios")
|
||||||
pub.unsubscribe(self.view_post, "open-post")
|
pub.unsubscribe(self.view_post, "open-post")
|
||||||
|
pub.unsubscribe(self.update_status_bar, "update-status-bar")
|
||||||
|
|
||||||
def login(self):
|
def login(self):
|
||||||
self.window.change_status(_(u"Logging in VK"))
|
self.window.change_status(_(u"Logging in VK"))
|
||||||
@ -148,3 +150,6 @@ class Controller(object):
|
|||||||
self.buffers.append(newbuff)
|
self.buffers.append(newbuff)
|
||||||
call_threaded(newbuff.get_items)
|
call_threaded(newbuff.get_items)
|
||||||
self.window.insert_buffer(newbuff.tab, _(u"Search for {0}").format(q.decode("utf-8"),), self.window.search("audios"))
|
self.window.insert_buffer(newbuff.tab, _(u"Search for {0}").format(q.decode("utf-8"),), self.window.search("audios"))
|
||||||
|
|
||||||
|
def update_status_bar(self, status):
|
||||||
|
self.window.change_status(status)
|
@ -3,6 +3,7 @@ import sound_lib
|
|||||||
from sound_lib.output import Output
|
from sound_lib.output import Output
|
||||||
from sound_lib.stream import URLStream
|
from sound_lib.stream import URLStream
|
||||||
from mysc.repeating_timer import RepeatingTimer
|
from mysc.repeating_timer import RepeatingTimer
|
||||||
|
from pubsub import pub
|
||||||
|
|
||||||
player = None
|
player = None
|
||||||
|
|
||||||
@ -33,7 +34,9 @@ class audioPlayer(object):
|
|||||||
# Make sure that there are no other sounds trying to be played.
|
# Make sure that there are no other sounds trying to be played.
|
||||||
if self.is_working == False:
|
if self.is_working == False:
|
||||||
self.is_working = True
|
self.is_working = True
|
||||||
self.stream = URLStream(url=url)
|
self.stream = URLStream(url=url["url"])
|
||||||
|
msg = _(u"Playing {0} by {1}").format(url["title"], url["artist"])
|
||||||
|
pub.sendMessage("update-status-bar", status=msg)
|
||||||
self.stream.volume = self.vol/100.0
|
self.stream.volume = self.vol/100.0
|
||||||
self.stream.play()
|
self.stream.play()
|
||||||
self.stopped = False
|
self.stopped = False
|
||||||
|
Loading…
Reference in New Issue
Block a user