Merge pull request #533 from afh/afh-play-paused-indicator

Change playing to paused on pause
This commit is contained in:
casey langen 2022-07-17 16:05:43 -07:00 committed by GitHub
commit dafa0bb713
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 1 deletions

View File

@ -140,6 +140,7 @@ void tokenize(const std::string& format, TokenList& tokens) {
static struct StringCache { static struct StringCache {
std::string PLAYING_FORMAT; std::string PLAYING_FORMAT;
std::string PLAYING; std::string PLAYING;
std::string PAUSED;
std::string BUFFERING; std::string BUFFERING;
std::string STOPPED; std::string STOPPED;
std::string EMPTY_SONG; std::string EMPTY_SONG;
@ -155,6 +156,7 @@ static struct StringCache {
void Initialize() { void Initialize() {
PLAYING_FORMAT = _TSTR("transport_playing_format"); PLAYING_FORMAT = _TSTR("transport_playing_format");
PLAYING = _TSTR("transport_playing_format_playing"); PLAYING = _TSTR("transport_playing_format_playing");
PAUSED = _TSTR("transport_playing_format_paused");
BUFFERING = _TSTR("transport_playing_format_buffering"); BUFFERING = _TSTR("transport_playing_format_buffering");
STOPPED = _TSTR("transport_stopped"); STOPPED = _TSTR("transport_stopped");
EMPTY_SONG = _TSTR("transport_empty_song"); EMPTY_SONG = _TSTR("transport_empty_song");
@ -307,7 +309,9 @@ size_t TransportWindow::WritePlayingFormat(WINDOW *w, size_t width) {
value = Strings.BUFFERING; value = Strings.BUFFERING;
} }
else { else {
value = Strings.PLAYING; auto const state = transport.GetPlaybackState();
bool const paused = (state != PlaybackState::Playing);
value = paused ? Strings.PAUSED : Strings.PLAYING;
} }
cols = u8len(value); cols = u8len(value);
} }
@ -387,6 +391,7 @@ TransportWindow::TransportWindow(
this->SetFrameVisible(false); this->SetFrameVisible(false);
this->playback.TrackChanged.connect(this, &TransportWindow::OnPlaybackServiceTrackChanged); this->playback.TrackChanged.connect(this, &TransportWindow::OnPlaybackServiceTrackChanged);
this->playback.ModeChanged.connect(this, &TransportWindow::OnPlaybackModeChanged); this->playback.ModeChanged.connect(this, &TransportWindow::OnPlaybackModeChanged);
this->playback.PlaybackStateChanged.connect(this, &TransportWindow::OnPlaybackStateChanged);
this->playback.Shuffled.connect(this, &TransportWindow::OnPlaybackShuffled); this->playback.Shuffled.connect(this, &TransportWindow::OnPlaybackShuffled);
this->playback.VolumeChanged.connect(this, &TransportWindow::OnTransportVolumeChanged); this->playback.VolumeChanged.connect(this, &TransportWindow::OnTransportVolumeChanged);
this->playback.TimeChanged.connect(this, &TransportWindow::OnTransportTimeChanged); this->playback.TimeChanged.connect(this, &TransportWindow::OnTransportTimeChanged);
@ -590,6 +595,10 @@ void TransportWindow::OnTransportVolumeChanged() {
DEBOUNCE_REFRESH(TimeMode::Sync, 0); DEBOUNCE_REFRESH(TimeMode::Sync, 0);
} }
void TransportWindow::OnPlaybackStateChanged(PlaybackState state) {
DEBOUNCE_REFRESH(TimeMode::Sync, 0);
}
void TransportWindow::OnTransportTimeChanged(double time) { void TransportWindow::OnTransportTimeChanged(double time) {
DEBOUNCE_REFRESH(TimeMode::Sync, 0); DEBOUNCE_REFRESH(TimeMode::Sync, 0);
} }

View File

@ -119,6 +119,7 @@ namespace musik {
void OnPlaybackServiceTrackChanged(size_t index, musik::core::TrackPtr track); void OnPlaybackServiceTrackChanged(size_t index, musik::core::TrackPtr track);
void OnPlaybackModeChanged(); void OnPlaybackModeChanged();
void OnPlaybackStateChanged(musik::core::sdk::PlaybackState);
void OnPlaybackStreamStateChanged(musik::core::sdk::StreamState); void OnPlaybackStreamStateChanged(musik::core::sdk::StreamState);
void OnTransportVolumeChanged(); void OnTransportVolumeChanged();
void OnTransportTimeChanged(double time); void OnTransportTimeChanged(double time);

View File

@ -206,6 +206,7 @@
"transport_playing_format": "$state $title by $artist from $album", "transport_playing_format": "$state $title by $artist from $album",
"transport_playing_format_playing": "playing", "transport_playing_format_playing": "playing",
"transport_playing_format_paused": "paused",
"transport_playing_format_buffering": "buffering", "transport_playing_format_buffering": "buffering",
"transport_stopped": "playback is stopped", "transport_stopped": "playback is stopped",
"transport_empty_song": "[song]", "transport_empty_song": "[song]",