forked from quickshell/quickshell
service/mpris: add isPlaying
This commit is contained in:
parent
db9e633197
commit
e2ef7b7982
2 changed files with 21 additions and 3 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue