Select songs with spacebar and play audio from selected tracks has been implemented

This commit is contained in:
Manuel Cortez 2019-05-02 05:57:49 -05:00
parent 194ca2d380
commit f1eb640564
3 changed files with 14 additions and 23 deletions

View File

@ -617,9 +617,6 @@ class documentCommunityBuffer(documentBuffer):
self.tab.post.Enable(False) self.tab.post.Enable(False)
class audioBuffer(feedBuffer): class audioBuffer(feedBuffer):
""" this buffer was supposed to be used with audio elements
but is deprecated as VK removed its audio support for third party apps."""
def create_tab(self, parent): def create_tab(self, parent):
self.tab = home.audioTab(parent) self.tab = home.audioTab(parent)
self.tab.name = self.name self.tab.name = self.name
@ -628,7 +625,7 @@ class audioBuffer(feedBuffer):
self.tab.post.Enable(True) self.tab.post.Enable(True)
def get_event(self, ev): def get_event(self, ev):
if ev.GetKeyCode() == wx.WXK_RETURN: event = "play_audio_from_keystroke" if ev.GetKeyCode() == wx.WXK_RETURN: event = "play_audio"
else: else:
event = None event = None
ev.Skip() ev.Skip()
@ -645,19 +642,16 @@ class audioBuffer(feedBuffer):
super(audioBuffer, self).connect_events() super(audioBuffer, self).connect_events()
def play_audio(self, *args, **kwargs): def play_audio(self, *args, **kwargs):
if player.player.stream != None: if player.player.check_is_playing():
return player.player.pause() return pub.sendMessage("pause")
selected = self.tab.list.get_selected() selected = self.tab.list.get_multiple_selection()
if selected == -1: if len(selected) == 0:
selected = 0 return
pub.sendMessage("play", object=self.session.db[self.name]["items"][selected]) elif len(selected) == 1:
return True pub.sendMessage("play", object=self.session.db[self.name]["items"][selected[0]])
else:
def play_audio_from_keystroke(self, *args, **kwargs): selected_audios = [self.session.db[self.name]["items"][item] for item in selected]
selected = self.tab.list.get_selected() pub.sendMessage("play-all", list_of_songs=selected_audios)
if selected == -1:
selected = 0
pub.sendMessage("play", object=self.session.db[self.name]["items"][selected])
return True return True
def play_next(self, *args, **kwargs): def play_next(self, *args, **kwargs):

View File

@ -120,7 +120,6 @@ class vkSession(object):
# log.exception("The session configuration has failed.") # log.exception("The session configuration has failed.")
def play_sound(self, sound): def play_sound(self, sound):
print(sound)
self.soundplayer.play(sound) self.soundplayer.play(sound)
def login(self): def login(self):

View File

@ -215,13 +215,11 @@ class multiselectionList(list):
for i in range(0, len(self.columns)): for i in range(0, len(self.columns)):
self.list.InsertColumn(i, "%s" % (self.columns[i])) self.list.InsertColumn(i, "%s" % (self.columns[i]))
def get_selected(self): def get_multiple_selection(self):
selected = [] selected = []
for item in range(0, self.list.GetItemCount()): for item in range(0, self.list.GetItemCount()):
if self.list.IsChecked(item): if self.list.IsChecked(item):
selected.append(item) selected.append(item)
if len(selected) == 1: if len(selected) == 0 and self.list.GetFocusedItem() != -1:
return selected selected.append(self.list.GetFocusedItem())
elif len(selected) == 0:
return self.list.GetFocusedItem()
return selected return selected