From a9032602bfdc60b9b3986997806dfde707931959 Mon Sep 17 00:00:00 2001 From: Manuel Cortez Date: Thu, 25 Apr 2019 08:56:12 -0500 Subject: [PATCH] Added play and pause functionality in the audios displayer --- changelog.md | 12 ++++++++++++ src/interactors/postDisplayer.py | 9 +++++++++ src/presenters/displayPosts/audio.py | 4 +++- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index 8e968bb..2fec32f 100644 --- a/changelog.md +++ b/changelog.md @@ -4,6 +4,18 @@ ### 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) * 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. diff --git a/src/interactors/postDisplayer.py b/src/interactors/postDisplayer.py index 8e86252..86089d6 100644 --- a/src/interactors/postDisplayer.py +++ b/src/interactors/postDisplayer.py @@ -171,6 +171,13 @@ class displayAudioInteractor(base.baseInteractor): getattr(self.view, control).Append(i) 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): super(displayAudioInteractor, self).install(*args, **kwargs) 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) pub.subscribe(self.set, self.modulename+"_set") pub.subscribe(self.add_items, self.modulename+"_add_items") + pub.subscribe(self.change_label, "playback-changed") def uninstall(self): super(displayAudioInteractor, self).uninstall() pub.unsubscribe(self.set, self.modulename+"_set") pub.unsubscribe(self.add_items, self.modulename+"_add_items") + pub.unsubscribe(self.change_label, "playback-changed") def on_change(self, *args, **kwargs): post = self.view.get_audio() diff --git a/src/presenters/displayPosts/audio.py b/src/presenters/displayPosts/audio.py index 52cbd78..9fda65e 100644 --- a/src/presenters/displayPosts/audio.py +++ b/src/presenters/displayPosts/audio.py @@ -3,7 +3,7 @@ import logging from sessionmanager import utils from pubsub import pub from mysc.thread_utils import call_threaded -from presenters import base +from presenters import base, player log = logging.getLogger(__file__) @@ -82,6 +82,8 @@ class displayAudioPresenter(base.basePresenter): def play(self, audio_index): post = self.post[audio_index] + if player.player.stream != None: + return player.player.pause() pub.sendMessage("play", object=post) def load_audios(self):