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 {
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);
}
@ -387,6 +391,7 @@ 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.VolumeChanged.connect(this, &TransportWindow::OnTransportVolumeChanged);
this->playback.TimeChanged.connect(this, &TransportWindow::OnTransportTimeChanged);
@ -590,6 +595,10 @@ void TransportWindow::OnTransportVolumeChanged() {
DEBOUNCE_REFRESH(TimeMode::Sync, 0);
}
void TransportWindow::OnPlaybackStateChanged(PlaybackState state) {
DEBOUNCE_REFRESH(TimeMode::Sync, 0);
}
void TransportWindow::OnTransportTimeChanged(double time) {
DEBOUNCE_REFRESH(TimeMode::Sync, 0);
}

View File

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

View File

@ -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]",