service/mpris: add isPlaying

This commit is contained in:
outfoxxed 2024-11-20 19:52:11 -08:00
parent db9e633197
commit e2ef7b7982
Signed by untrusted user: outfoxxed
GPG key ID: 4C88A185FB89301E
2 changed files with 21 additions and 3 deletions

View file

@ -65,8 +65,7 @@ MprisPlayer::MprisPlayer(const QString& address, QObject* parent): QObject(paren
this->bCanGoPrevious.setBinding([this]() { return this->bCanControl && this->bpCanGoPrevious; });
this->bCanTogglePlaying.setBinding([this]() {
return this->bPlaybackState == MprisPlaybackState::Playing ? this->bCanPause.value()
: this->bCanPlay.value();
return this->bIsPlaying ? this->bCanPause.value() : this->bCanPlay.value();
});
this->bTrackTitle.setBinding([this]() {
@ -116,6 +115,10 @@ MprisPlayer::MprisPlayer(const QString& address, QObject* parent): QObject(paren
}
});
this->bIsPlaying.setBinding([this]() {
return this->bPlaybackState == MprisPlaybackState::Playing;
});
this->bLoopState.setBinding([this]() {
const auto& status = this->bpLoopStatus.value();
@ -368,13 +371,18 @@ void MprisPlayer::pause() { this->setPlaybackState(MprisPlaybackState::Paused);
void MprisPlayer::stop() { this->setPlaybackState(MprisPlaybackState::Stopped); }
void MprisPlayer::togglePlaying() {
if (this->bPlaybackState == MprisPlaybackState::Playing) {
if (this->bIsPlaying) {
this->pause();
} else {
this->play();
}
}
void MprisPlayer::setPlaying(bool playing) {
if (playing == this->bIsPlaying) return;
this->togglePlaying();
}
bool MprisPlayer::loopSupported() const { return this->pLoopStatus.exists(); }
void MprisPlayer::setLoopState(MprisLoopState::Enum loopState) {