Added play and pause functionality in the audios displayer

This commit is contained in:
Manuel Cortez 2019-04-25 08:56:12 -05:00
parent 8c03601bd2
commit a9032602bf
3 changed files with 24 additions and 1 deletions

View File

@ -4,6 +4,18 @@
### New additions ### New additions
### bugfixes
### Changes
* the audio player module has received some improvements:
- When there is something being played, the label of the "play" button, located in all audio buffers, will change automatically to "pause". When pressed, it will pause the song instead of starting the playback again since the beginning.
- The last change will work also in the dialog for displaying audio information. Now it's possible to play and pause an audio from such dialog.
## changes in version 0.20 (25.04.2019)
### New additions
* For users with multiple soundcards, there is a new tab in the preferences dialogue of Socializer, called sound. From there, you can define which soundcard will be used for input and output. [#25,](https://code.manuelcortez.net/manuelcortez/socializer/issues/25) * For users with multiple soundcards, there is a new tab in the preferences dialogue of Socializer, called sound. From there, you can define which soundcard will be used for input and output. [#25,](https://code.manuelcortez.net/manuelcortez/socializer/issues/25)
* the audio player can seek positions in the currently playing track. You can use the menu items (located in the main menu) or use the new available keystrokes dedicated to the actions. Seeking will be made in 5 second intervals. * the audio player can seek positions in the currently playing track. You can use the menu items (located in the main menu) or use the new available keystrokes dedicated to the actions. Seeking will be made in 5 second intervals.
* Alt+Shift+Left arrow: Seek 5 seconds backwards. * Alt+Shift+Left arrow: Seek 5 seconds backwards.

View File

@ -171,6 +171,13 @@ class displayAudioInteractor(base.baseInteractor):
getattr(self.view, control).Append(i) getattr(self.view, control).Append(i)
getattr(self.view, control).SetSelection(0) getattr(self.view, control).SetSelection(0)
def change_label(self, stopped):
if stopped == False:
self.view.play.SetLabel(_("P&ause"))
else:
self.view.play.SetLabel(_("P&lay"))
def install(self, *args, **kwargs): def install(self, *args, **kwargs):
super(displayAudioInteractor, self).install(*args, **kwargs) super(displayAudioInteractor, self).install(*args, **kwargs)
widgetUtils.connect_event(self.view.list, widgetUtils.LISTBOX_CHANGED, self.on_change) widgetUtils.connect_event(self.view.list, widgetUtils.LISTBOX_CHANGED, self.on_change)
@ -180,11 +187,13 @@ class displayAudioInteractor(base.baseInteractor):
widgetUtils.connect_event(self.view.remove, widgetUtils.BUTTON_PRESSED, self.on_remove_from_library) widgetUtils.connect_event(self.view.remove, widgetUtils.BUTTON_PRESSED, self.on_remove_from_library)
pub.subscribe(self.set, self.modulename+"_set") pub.subscribe(self.set, self.modulename+"_set")
pub.subscribe(self.add_items, self.modulename+"_add_items") pub.subscribe(self.add_items, self.modulename+"_add_items")
pub.subscribe(self.change_label, "playback-changed")
def uninstall(self): def uninstall(self):
super(displayAudioInteractor, self).uninstall() super(displayAudioInteractor, self).uninstall()
pub.unsubscribe(self.set, self.modulename+"_set") pub.unsubscribe(self.set, self.modulename+"_set")
pub.unsubscribe(self.add_items, self.modulename+"_add_items") pub.unsubscribe(self.add_items, self.modulename+"_add_items")
pub.unsubscribe(self.change_label, "playback-changed")
def on_change(self, *args, **kwargs): def on_change(self, *args, **kwargs):
post = self.view.get_audio() post = self.view.get_audio()

View File

@ -3,7 +3,7 @@ import logging
from sessionmanager import utils from sessionmanager import utils
from pubsub import pub from pubsub import pub
from mysc.thread_utils import call_threaded from mysc.thread_utils import call_threaded
from presenters import base from presenters import base, player
log = logging.getLogger(__file__) log = logging.getLogger(__file__)
@ -82,6 +82,8 @@ class displayAudioPresenter(base.basePresenter):
def play(self, audio_index): def play(self, audio_index):
post = self.post[audio_index] post = self.post[audio_index]
if player.player.stream != None:
return player.player.pause()
pub.sendMessage("play", object=post) pub.sendMessage("play", object=post)
def load_audios(self): def load_audios(self):