From 36a55767c1b6ad9207a5a2d29582a7072679697d Mon Sep 17 00:00:00 2001 From: Alexis Hildebrandt Date: Wed, 13 Jul 2022 09:52:06 +0200 Subject: [PATCH 1/3] Change playing to paused on pause to indicate play-pause-state in addition to blinking elapsed time --- src/musikcore/audio/PlaybackService.cpp | 4 ++++ src/musikcore/audio/PlaybackService.h | 1 + src/musikcube/app/window/TransportWindow.cpp | 11 ++++++++++- src/musikcube/app/window/TransportWindow.h | 1 + src/musikcube/data/locales/en_US.json | 1 + 5 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/musikcore/audio/PlaybackService.cpp b/src/musikcore/audio/PlaybackService.cpp index f9a265b03..cfae69033 100755 --- a/src/musikcore/audio/PlaybackService.cpp +++ b/src/musikcore/audio/PlaybackService.cpp @@ -787,6 +787,7 @@ void PlaybackService::PauseOrResume() { else if (state == PlaybackState::Playing) { transport->Pause(); } + this->PlayPauseChanged(); } bool PlaybackService::IsMuted() { @@ -936,6 +937,9 @@ void PlaybackService::OnStreamEvent(StreamState eventType, std::string uri) { void PlaybackService::OnPlaybackEvent(PlaybackState eventType) { POST(this, MESSAGE_PLAYBACK_EVENT, (int64_t) eventType, 0); + if (eventType == PlaybackState::Paused || eventType == PlaybackState::Playing) { + this->PlayPauseChanged(); + } } void PlaybackService::OnVolumeChanged() { diff --git a/src/musikcore/audio/PlaybackService.h b/src/musikcore/audio/PlaybackService.h index fc4391315..95052eb69 100755 --- a/src/musikcore/audio/PlaybackService.h +++ b/src/musikcore/audio/PlaybackService.h @@ -58,6 +58,7 @@ namespace musik { namespace core { namespace audio { /* our unique events */ sigslot::signal2 TrackChanged; sigslot::signal0<> ModeChanged; + sigslot::signal0<> PlayPauseChanged; sigslot::signal1 Shuffled; sigslot::signal0<> QueueEdited; diff --git a/src/musikcube/app/window/TransportWindow.cpp b/src/musikcube/app/window/TransportWindow.cpp index 1ccd7bfec..1c98aeef9 100755 --- a/src/musikcube/app/window/TransportWindow.cpp +++ b/src/musikcube/app/window/TransportWindow.cpp @@ -140,6 +140,7 @@ void tokenize(const std::string& format, TokenList& tokens) { static struct StringCache { std::string PLAYING_FORMAT; std::string PLAYING; + std::string PAUSED; std::string BUFFERING; std::string STOPPED; std::string EMPTY_SONG; @@ -155,6 +156,7 @@ static struct StringCache { void Initialize() { PLAYING_FORMAT = _TSTR("transport_playing_format"); PLAYING = _TSTR("transport_playing_format_playing"); + PAUSED = _TSTR("transport_playing_format_paused"); BUFFERING = _TSTR("transport_playing_format_buffering"); STOPPED = _TSTR("transport_stopped"); EMPTY_SONG = _TSTR("transport_empty_song"); @@ -307,7 +309,9 @@ size_t TransportWindow::WritePlayingFormat(WINDOW *w, size_t width) { value = Strings.BUFFERING; } else { - value = Strings.PLAYING; + auto const state = transport.GetPlaybackState(); + bool const paused = (state != PlaybackState::Playing); + value = paused ? Strings.PAUSED : Strings.PLAYING; } cols = u8len(value); } @@ -388,6 +392,7 @@ TransportWindow::TransportWindow( this->playback.TrackChanged.connect(this, &TransportWindow::OnPlaybackServiceTrackChanged); this->playback.ModeChanged.connect(this, &TransportWindow::OnPlaybackModeChanged); this->playback.Shuffled.connect(this, &TransportWindow::OnPlaybackShuffled); + this->playback.PlayPauseChanged.connect(this, &TransportWindow::OnPlayPauseChanged); this->playback.VolumeChanged.connect(this, &TransportWindow::OnTransportVolumeChanged); this->playback.TimeChanged.connect(this, &TransportWindow::OnTransportTimeChanged); this->playback.StreamStateChanged.connect(this, &TransportWindow::OnPlaybackStreamStateChanged); @@ -590,6 +595,10 @@ void TransportWindow::OnTransportVolumeChanged() { DEBOUNCE_REFRESH(TimeMode::Sync, 0); } +void TransportWindow::OnPlayPauseChanged() { + DEBOUNCE_REFRESH(TimeMode::Sync, 0); +} + void TransportWindow::OnTransportTimeChanged(double time) { DEBOUNCE_REFRESH(TimeMode::Sync, 0); } diff --git a/src/musikcube/app/window/TransportWindow.h b/src/musikcube/app/window/TransportWindow.h index 2fc3f7b16..6ae461c9a 100755 --- a/src/musikcube/app/window/TransportWindow.h +++ b/src/musikcube/app/window/TransportWindow.h @@ -119,6 +119,7 @@ namespace musik { void OnPlaybackServiceTrackChanged(size_t index, musik::core::TrackPtr track); void OnPlaybackModeChanged(); + void OnPlayPauseChanged(); void OnPlaybackStreamStateChanged(musik::core::sdk::StreamState); void OnTransportVolumeChanged(); void OnTransportTimeChanged(double time); diff --git a/src/musikcube/data/locales/en_US.json b/src/musikcube/data/locales/en_US.json index ed747d044..945a21f9d 100644 --- a/src/musikcube/data/locales/en_US.json +++ b/src/musikcube/data/locales/en_US.json @@ -206,6 +206,7 @@ "transport_playing_format": "$state $title by $artist from $album", "transport_playing_format_playing": "playing", + "transport_playing_format_paused": "paused", "transport_playing_format_buffering": "buffering", "transport_stopped": "playback is stopped", "transport_empty_song": "[song]", From 411980fe2ac15a018406c59b97a6c843bb21c320 Mon Sep 17 00:00:00 2001 From: Alexis Hildebrandt Date: Sun, 17 Jul 2022 10:44:50 +0200 Subject: [PATCH 2/3] Remove unnecessary PlayPauseChanged signal and use existing PlaybackStateChanged signal. --- src/musikcore/audio/PlaybackService.cpp | 3 +-- src/musikcore/audio/PlaybackService.h | 1 - src/musikcube/app/window/TransportWindow.cpp | 4 ++-- src/musikcube/app/window/TransportWindow.h | 2 +- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/musikcore/audio/PlaybackService.cpp b/src/musikcore/audio/PlaybackService.cpp index cfae69033..92c64f01e 100755 --- a/src/musikcore/audio/PlaybackService.cpp +++ b/src/musikcore/audio/PlaybackService.cpp @@ -787,7 +787,6 @@ void PlaybackService::PauseOrResume() { else if (state == PlaybackState::Playing) { transport->Pause(); } - this->PlayPauseChanged(); } bool PlaybackService::IsMuted() { @@ -938,7 +937,7 @@ void PlaybackService::OnStreamEvent(StreamState eventType, std::string uri) { void PlaybackService::OnPlaybackEvent(PlaybackState eventType) { POST(this, MESSAGE_PLAYBACK_EVENT, (int64_t) eventType, 0); if (eventType == PlaybackState::Paused || eventType == PlaybackState::Playing) { - this->PlayPauseChanged(); + this->PlaybackStateChanged(static_cast(eventType)); } } diff --git a/src/musikcore/audio/PlaybackService.h b/src/musikcore/audio/PlaybackService.h index 95052eb69..fc4391315 100755 --- a/src/musikcore/audio/PlaybackService.h +++ b/src/musikcore/audio/PlaybackService.h @@ -58,7 +58,6 @@ namespace musik { namespace core { namespace audio { /* our unique events */ sigslot::signal2 TrackChanged; sigslot::signal0<> ModeChanged; - sigslot::signal0<> PlayPauseChanged; sigslot::signal1 Shuffled; sigslot::signal0<> QueueEdited; diff --git a/src/musikcube/app/window/TransportWindow.cpp b/src/musikcube/app/window/TransportWindow.cpp index 1c98aeef9..c132c7fe7 100755 --- a/src/musikcube/app/window/TransportWindow.cpp +++ b/src/musikcube/app/window/TransportWindow.cpp @@ -391,8 +391,8 @@ TransportWindow::TransportWindow( this->SetFrameVisible(false); this->playback.TrackChanged.connect(this, &TransportWindow::OnPlaybackServiceTrackChanged); this->playback.ModeChanged.connect(this, &TransportWindow::OnPlaybackModeChanged); + this->playback.PlaybackStateChanged.connect(this, &TransportWindow::OnPlaybackStateChanged); this->playback.Shuffled.connect(this, &TransportWindow::OnPlaybackShuffled); - this->playback.PlayPauseChanged.connect(this, &TransportWindow::OnPlayPauseChanged); this->playback.VolumeChanged.connect(this, &TransportWindow::OnTransportVolumeChanged); this->playback.TimeChanged.connect(this, &TransportWindow::OnTransportTimeChanged); this->playback.StreamStateChanged.connect(this, &TransportWindow::OnPlaybackStreamStateChanged); @@ -595,7 +595,7 @@ void TransportWindow::OnTransportVolumeChanged() { DEBOUNCE_REFRESH(TimeMode::Sync, 0); } -void TransportWindow::OnPlayPauseChanged() { +void TransportWindow::OnPlaybackStateChanged(PlaybackState state) { DEBOUNCE_REFRESH(TimeMode::Sync, 0); } diff --git a/src/musikcube/app/window/TransportWindow.h b/src/musikcube/app/window/TransportWindow.h index 6ae461c9a..dc10066bf 100755 --- a/src/musikcube/app/window/TransportWindow.h +++ b/src/musikcube/app/window/TransportWindow.h @@ -119,7 +119,7 @@ namespace musik { void OnPlaybackServiceTrackChanged(size_t index, musik::core::TrackPtr track); void OnPlaybackModeChanged(); - void OnPlayPauseChanged(); + void OnPlaybackStateChanged(musik::core::sdk::PlaybackState); void OnPlaybackStreamStateChanged(musik::core::sdk::StreamState); void OnTransportVolumeChanged(); void OnTransportTimeChanged(double time); From 7fd9ebd550bd50243b5076a6a8c2d7e6577aa203 Mon Sep 17 00:00:00 2001 From: Alexis Hildebrandt Date: Sun, 17 Jul 2022 21:40:49 +0200 Subject: [PATCH 3/3] Remove unnecessary code --- src/musikcore/audio/PlaybackService.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/musikcore/audio/PlaybackService.cpp b/src/musikcore/audio/PlaybackService.cpp index 92c64f01e..f9a265b03 100755 --- a/src/musikcore/audio/PlaybackService.cpp +++ b/src/musikcore/audio/PlaybackService.cpp @@ -936,9 +936,6 @@ void PlaybackService::OnStreamEvent(StreamState eventType, std::string uri) { void PlaybackService::OnPlaybackEvent(PlaybackState eventType) { POST(this, MESSAGE_PLAYBACK_EVENT, (int64_t) eventType, 0); - if (eventType == PlaybackState::Paused || eventType == PlaybackState::Playing) { - this->PlaybackStateChanged(static_cast(eventType)); - } } void PlaybackService::OnVolumeChanged() {