Added audio player menu in menu bar
This commit is contained in:
parent
740ae124f9
commit
00d7cf48af
@ -1,6 +1,10 @@
|
||||
% Changelog
|
||||
|
||||
## Changes for the current build (08/07/2016)
|
||||
## Changes in the current build ()
|
||||
|
||||
* Added a new menu in the menu bar that allows you to control the audio playback. For some actions (like play, next and back), if you are not focusing an audio buffer, the program will take the song from the "my audios" buffer.
|
||||
|
||||
## Changes in build 2016.07.08 (08/07/2016)
|
||||
|
||||
* Removed platform from "last seen" column in the friends list as it could cause some problems and it was being not so exact.
|
||||
* Now deleted audios are not parsed and displayed as "audio removed from library". They are silently ignored.
|
||||
|
@ -219,9 +219,13 @@ class baseBuffer(object):
|
||||
player.player.volume = player.player.volume+5
|
||||
|
||||
def play_audio(self, *args, **kwargs):
|
||||
post = self.session.db[self.name]["items"][self.tab.list.get_selected()]
|
||||
selected = self.tab.list.get_selected()
|
||||
if selected == -1:
|
||||
selected = 0
|
||||
post = self.session.db[self.name]["items"][selected]
|
||||
if post.has_key("type") and post["type"] == "audio":
|
||||
pub.sendMessage("play-audio", audio_object=post["audio"]["items"][0])
|
||||
return True
|
||||
|
||||
def open_post(self, *args, **kwargs):
|
||||
post = self.session.db[self.name]["items"][self.tab.list.get_selected()]
|
||||
@ -308,7 +312,29 @@ class audioBuffer(feedBuffer):
|
||||
|
||||
def play_audio(self, *args, **kwargs):
|
||||
selected = self.tab.list.get_selected()
|
||||
if selected == -1:
|
||||
selected = 0
|
||||
pub.sendMessage("play-audio", audio_object=self.session.db[self.name]["items"][selected])
|
||||
return True
|
||||
|
||||
def play_next(self, *args, **kwargs):
|
||||
selected = self.tab.list.get_selected()
|
||||
if selected < 0 or selected == self.tab.list.get_count()-1:
|
||||
selected = 0
|
||||
if self.tab.list.get_count() <= selected+1:
|
||||
newpos = 0
|
||||
else:
|
||||
newpos = selected+1
|
||||
self.tab.list.select_item(newpos)
|
||||
self.play_audio()
|
||||
|
||||
def play_previous(self, *args, **kwargs):
|
||||
selected = self.tab.list.get_selected()
|
||||
if selected <= 0:
|
||||
selected = self.tab.list.get_count()
|
||||
newpos = selected-1
|
||||
self.tab.list.select_item(newpos)
|
||||
self.play_audio()
|
||||
|
||||
def open_post(self, *args, **kwargs):
|
||||
selected = self.tab.list.get_selected()
|
||||
@ -323,6 +349,7 @@ class audioBuffer(feedBuffer):
|
||||
selected = 0
|
||||
audios = [i for i in self.session.db[self.name]["items"][selected:]]
|
||||
pub.sendMessage("play-audios", audios=audios)
|
||||
return True
|
||||
|
||||
def remove_buffer(self, mandatory=False):
|
||||
if "me_audio" == self.name or "popular_audio" == self.name or "recommended_audio" == self.name:
|
||||
@ -500,7 +527,7 @@ class peopleBuffer(feedBuffer):
|
||||
|
||||
def open_post(self, *args, **kwargs): pass
|
||||
|
||||
def play_audio(self, *args, **kwargs): pass
|
||||
def play_audio(self, *args, **kwargs): return False
|
||||
|
||||
def pause_audio(self, *args, **kwargs): pass
|
||||
|
||||
|
@ -129,6 +129,14 @@ class Controller(object):
|
||||
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.create_audio_album, menuitem=self.window.audio_album)
|
||||
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.delete_audio_album, menuitem=self.window.delete_audio_album)
|
||||
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.check_documentation, menuitem=self.window.documentation)
|
||||
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.menu_play_pause, menuitem=self.window.player_play)
|
||||
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.menu_play_next, menuitem=self.window.player_next)
|
||||
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.menu_play_previous, menuitem=self.window.player_previous)
|
||||
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.menu_play_all, menuitem=self.window.player_play_all)
|
||||
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.menu_stop, menuitem=self.window.player_stop)
|
||||
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.menu_volume_down, menuitem=self.window.player_volume_down)
|
||||
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.menu_volume_up, menuitem=self.window.player_volume_up)
|
||||
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.menu_mute, menuitem=self.window.player_mute)
|
||||
pub.subscribe(self.get_chat, "order-sent-message")
|
||||
|
||||
def disconnect_events(self):
|
||||
@ -411,3 +419,47 @@ class Controller(object):
|
||||
os.chdir("documentation/%s" % (lang,))
|
||||
webbrowser.open("manual.html")
|
||||
os.chdir("../../")
|
||||
|
||||
def menu_play_pause(self, *args, **kwargs):
|
||||
if player.player.check_is_playing() != False:
|
||||
return player.player.pause()
|
||||
b = self.get_current_buffer()
|
||||
if hasattr(b, "play_audio"):
|
||||
b.play_audio()
|
||||
else:
|
||||
b = self.search("me_audio")
|
||||
b.play_audio()
|
||||
|
||||
def menu_play_next(self, *args, **kwargs):
|
||||
b = self.get_current_buffer()
|
||||
if hasattr(b, "play_next"):
|
||||
b.play_next()
|
||||
else:
|
||||
self.search("me_audio").play_next()
|
||||
|
||||
def menu_play_previous(self, *args, **kwargs):
|
||||
b = self.get_current_buffer()
|
||||
if hasattr(b, "play_previous"):
|
||||
b.play_previous()
|
||||
else:
|
||||
self.search("me_audio").play_previous()
|
||||
|
||||
def menu_play_all(self, *args, **kwargs):
|
||||
b = self.get_current_buffer()
|
||||
if hasattr(b, "play_all"):
|
||||
b.play_all()
|
||||
else:
|
||||
self.search("me_audio").play_all()
|
||||
|
||||
def menu_stop(self, *args, **kwargs):
|
||||
player.player.stop()
|
||||
|
||||
def menu_volume_down(self, *args, **kwargs):
|
||||
player.player.volume = player.player.volume-5
|
||||
|
||||
def menu_volume_up(self, *args, **kwargs):
|
||||
player.player.volume = player.player.volume+5
|
||||
|
||||
def menu_mute(self, *args, **kwargs):
|
||||
player.player.volume = 0
|
||||
|
||||
|
@ -87,3 +87,12 @@ class audioPlayer(object):
|
||||
return
|
||||
self.play(self.queue[0])
|
||||
self.queue.remove(self.queue[0])
|
||||
|
||||
def check_is_playing(self):
|
||||
if self.stream == None:
|
||||
return False
|
||||
if self.stream != None and self.stream.is_playing == False:
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
|
@ -23,11 +23,21 @@ class mainWindow(wx.Frame):
|
||||
self.remove_buffer_ = buffer.Append(wx.NewId(), _(u"&Remove buffer"))
|
||||
mb.Append(app_, _(u"Application"))
|
||||
mb.Append(buffer, _(u"Buffer"))
|
||||
player = wx.Menu()
|
||||
self.player_play = player.Append(wx.NewId(), _(u"Play"))
|
||||
self.player_play_all = player.Append(wx.NewId(), _(u"Play all"))
|
||||
self.player_stop = player.Append(wx.NewId(), _(u"Stop"))
|
||||
self.player_previous = player.Append(wx.NewId(), _(u"Previous"))
|
||||
self.player_next = player.Append(wx.NewId(), _(u"Next"))
|
||||
self.player_volume_down = player.Append(wx.NewId(), _(u"Volume down"))
|
||||
self.player_volume_up = player.Append(wx.NewId(), _(u"Volume up"))
|
||||
self.player_mute = player.Append(wx.NewId(), _(u"Mute"))
|
||||
help_ = wx.Menu()
|
||||
self.about = help_.Append(wx.NewId(), _(u"About {0}").format(application.name,))
|
||||
self.documentation = help_.Append(wx.NewId(), _(u"Manual"))
|
||||
self.check_for_updates = help_.Append(wx.NewId(), _(u"Check for updates"))
|
||||
self.changelog = help_.Append(wx.NewId(), _(u"Chan&gelog"))
|
||||
mb.Append(player, _(u"Audio player"))
|
||||
mb.Append(help_, _(u"Help"))
|
||||
self.SetMenuBar(mb)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user