Updated software
This commit is contained in:
parent
9e06e0c29e
commit
86cfb3bf94
@ -44,10 +44,9 @@ class Controller(object):
|
|||||||
widgetUtils.connect_event(self.window.search, widgetUtils.BUTTON_PRESSED, self.on_search)
|
widgetUtils.connect_event(self.window.search, widgetUtils.BUTTON_PRESSED, self.on_search)
|
||||||
widgetUtils.connect_event(self.window.list, widgetUtils.LISTBOX_ITEM_ACTIVATED, self.on_activated)
|
widgetUtils.connect_event(self.window.list, widgetUtils.LISTBOX_ITEM_ACTIVATED, self.on_activated)
|
||||||
widgetUtils.connect_event(self.window.list, widgetUtils.KEYPRESS, self.on_keypress)
|
widgetUtils.connect_event(self.window.list, widgetUtils.KEYPRESS, self.on_keypress)
|
||||||
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.on_play_pause, menuitem=self.window.player_play)
|
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.on_play, menuitem=self.window.player_play)
|
||||||
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.on_next, menuitem=self.window.player_next)
|
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.on_next, menuitem=self.window.player_next)
|
||||||
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.on_previous, menuitem=self.window.player_previous)
|
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.on_previous, menuitem=self.window.player_previous)
|
||||||
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.on_play_all, menuitem=self.window.player_play_all)
|
|
||||||
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.on_stop, menuitem=self.window.player_stop)
|
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.on_stop, menuitem=self.window.player_stop)
|
||||||
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.on_volume_down, menuitem=self.window.player_volume_down)
|
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.on_volume_down, menuitem=self.window.player_volume_down)
|
||||||
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.on_volume_up, menuitem=self.window.player_volume_up)
|
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.on_volume_up, menuitem=self.window.player_volume_up)
|
||||||
@ -59,23 +58,28 @@ class Controller(object):
|
|||||||
utils.call_threaded(self.search)
|
utils.call_threaded(self.search)
|
||||||
|
|
||||||
def on_activated(self, *args, **kwargs):
|
def on_activated(self, *args, **kwargs):
|
||||||
utils.call_threaded(self.play)
|
self.on_play()
|
||||||
|
|
||||||
def on_keypress(self, ev):
|
def on_keypress(self, ev):
|
||||||
if ev.GetKeyCode() == wx.WXK_RETURN:
|
if ev.GetKeyCode() == wx.WXK_RETURN:
|
||||||
utils.call_threaded(self.play)
|
self.on_play()
|
||||||
|
elif ev.GetKeyCode() == wx.WXK_SPACE:
|
||||||
|
self.on_play_pause()
|
||||||
ev.Skip()
|
ev.Skip()
|
||||||
|
|
||||||
def on_play_pause(self, *args, **kwargs):
|
def on_play_pause(self, *args, **kwargs):
|
||||||
if player.player.check_is_playing() != False:
|
if player.player.check_is_playing() != False:
|
||||||
return player.player.pause()
|
return player.player.pause()
|
||||||
return utils.call_threaded(self.play)
|
elif player.player.stream != None:
|
||||||
|
player.player.stream.play()
|
||||||
|
else:
|
||||||
|
self.on_play()
|
||||||
|
|
||||||
def on_next(self, *args, **kwargs):
|
def on_next(self, *args, **kwargs):
|
||||||
if len(self.results) == 0:
|
if len(self.results) == 0:
|
||||||
return
|
return
|
||||||
item = self.window.get_item()
|
item = self.window.get_item()
|
||||||
if item <= len(self.results):
|
if item < len(self.results)-1:
|
||||||
self.window.list.SetSelection(item+1)
|
self.window.list.SetSelection(item+1)
|
||||||
else:
|
else:
|
||||||
self.window.list.SetSelection(0)
|
self.window.list.SetSelection(0)
|
||||||
@ -91,8 +95,10 @@ class Controller(object):
|
|||||||
self.window.list.SetSelection(len(self.results)-1)
|
self.window.list.SetSelection(len(self.results)-1)
|
||||||
return utils.call_threaded(self.play)
|
return utils.call_threaded(self.play)
|
||||||
|
|
||||||
def on_play_all(self, *args, **kwargs):
|
def on_play(self, *args, **kwargs):
|
||||||
pass
|
items = self.results[self.window.get_item():]
|
||||||
|
return utils.call_threaded(player.player.play_all, items, shuffle=self.window.player_shuffle.IsChecked(), extractor=self.extractor)
|
||||||
|
|
||||||
|
|
||||||
def on_stop(self, *args, **kwargs):
|
def on_stop(self, *args, **kwargs):
|
||||||
player.player.stop()
|
player.player.stop()
|
||||||
@ -122,14 +128,3 @@ class Controller(object):
|
|||||||
for i in self.results:
|
for i in self.results:
|
||||||
self.window.list.Append(i.format_track())
|
self.window.list.Append(i.format_track())
|
||||||
self.change_status("")
|
self.change_status("")
|
||||||
|
|
||||||
def play(self):
|
|
||||||
if len(self.results) == 0:
|
|
||||||
return
|
|
||||||
self.change_status(_("Loading song..."))
|
|
||||||
url = self.extractor.get_download_url(self.results[self.window.get_item()].url)
|
|
||||||
player.player.play(url)
|
|
||||||
|
|
||||||
def play_audios(self, audios):
|
|
||||||
player.player.play_all(audios, shuffle=self.window.player_shuffle.IsChecked())
|
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ class audioPlayer(object):
|
|||||||
self.queue = []
|
self.queue = []
|
||||||
self.stopped = True
|
self.stopped = True
|
||||||
|
|
||||||
def play(self, url):
|
def play(self, item):
|
||||||
if self.stream != None and self.stream.is_playing == True:
|
if self.stream != None and self.stream.is_playing == True:
|
||||||
try:
|
try:
|
||||||
self.stream.stop()
|
self.stream.stop()
|
||||||
@ -42,14 +42,17 @@ class audioPlayer(object):
|
|||||||
# Make sure there are no other sounds trying to be played.
|
# Make sure 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
|
||||||
|
if item.download_url == "" and hasattr(self, "extractor"):
|
||||||
|
item.download_url = self.extractor.get_download_url(item.url)
|
||||||
try:
|
try:
|
||||||
self.stream = URLStream(url=url)
|
self.stream = URLStream(url=item.download_url)
|
||||||
except BassError:
|
except BassError:
|
||||||
log.debug("Error when playing the file {0}".format(url,))
|
log.debug("Error when playing the file {0}".format(item.title,))
|
||||||
pub.sendMessage("change_status", status=_("Error playing last file"))
|
pub.sendMessage("change_status", status=_("Error playing last file"))
|
||||||
return
|
return
|
||||||
self.stream.volume = self.vol/100.0
|
self.stream.volume = self.vol/100.0
|
||||||
self.stream.play()
|
self.stream.play()
|
||||||
|
pub.sendMessage("change_status", status=_("Playing {0}.").format(item.title))
|
||||||
self.stopped = False
|
self.stopped = False
|
||||||
self.is_working = False
|
self.is_working = False
|
||||||
|
|
||||||
@ -76,7 +79,7 @@ class audioPlayer(object):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def volume(self):
|
def volume(self):
|
||||||
if self.stream != None:
|
# if self.stream != None:
|
||||||
return self.vol
|
return self.vol
|
||||||
|
|
||||||
@volume.setter
|
@volume.setter
|
||||||
@ -86,9 +89,10 @@ class audioPlayer(object):
|
|||||||
if self.stream != None:
|
if self.stream != None:
|
||||||
self.stream.volume = self.vol/100.0
|
self.stream.volume = self.vol/100.0
|
||||||
|
|
||||||
def play_all(self, list_of_urls, shuffle=False):
|
def play_all(self, list_of_urls, shuffle=False, extractor=None):
|
||||||
self.stop()
|
self.stop()
|
||||||
self.queue = list_of_urls
|
self.queue = list_of_urls
|
||||||
|
self.extractor = extractor
|
||||||
if shuffle:
|
if shuffle:
|
||||||
random.shuffle(self.queue)
|
random.shuffle(self.queue)
|
||||||
self.play(self.queue[0])
|
self.play(self.queue[0])
|
||||||
|
@ -11,6 +11,7 @@ class song(object):
|
|||||||
self.duration = ""
|
self.duration = ""
|
||||||
self.size = 0
|
self.size = 0
|
||||||
self.url = ""
|
self.url = ""
|
||||||
|
self.download_url = ""
|
||||||
|
|
||||||
def format_track(self):
|
def format_track(self):
|
||||||
return "{0}. {1}. {2}".format(self.title, self.duration, self.size)
|
return "{0}. {1}. {2}".format(self.title, self.duration, self.size)
|
@ -10,7 +10,6 @@ class mainWindow(wx.Frame):
|
|||||||
mb.Append(app_, _(u"Application"))
|
mb.Append(app_, _(u"Application"))
|
||||||
player = wx.Menu()
|
player = wx.Menu()
|
||||||
self.player_play = player.Append(wx.NewId(), _(u"Play"))
|
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_stop = player.Append(wx.NewId(), _(u"Stop"))
|
||||||
self.player_previous = player.Append(wx.NewId(), _(u"Previous"))
|
self.player_previous = player.Append(wx.NewId(), _(u"Previous"))
|
||||||
self.player_next = player.Append(wx.NewId(), _(u"Next"))
|
self.player_next = player.Append(wx.NewId(), _(u"Next"))
|
||||||
|
Loading…
Reference in New Issue
Block a user