forked from quickshell/quickshell
service/mpris: re-query position on playback and metadata change
This commit is contained in:
parent
ac339cb23b
commit
6326f60ce2
|
@ -267,7 +267,8 @@ void MprisPlayer::onMetadataChanged() {
|
||||||
emit this->trackChanged();
|
emit this->trackChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
this->onSeek(0);
|
// Some players don't seem to send position updats or seeks on track change.
|
||||||
|
this->pPosition.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
emit this->metadataChanged();
|
emit this->metadataChanged();
|
||||||
|
@ -313,21 +314,25 @@ void MprisPlayer::setPlaybackState(MprisPlaybackState::Enum playbackState) {
|
||||||
void MprisPlayer::onPlaybackStatusChanged() {
|
void MprisPlayer::onPlaybackStatusChanged() {
|
||||||
const auto& status = this->pPlaybackStatus.get();
|
const auto& status = this->pPlaybackStatus.get();
|
||||||
|
|
||||||
|
auto state = MprisPlaybackState::Stopped;
|
||||||
if (status == "Playing") {
|
if (status == "Playing") {
|
||||||
// update the timestamp
|
state = MprisPlaybackState::Playing;
|
||||||
this->onSeek(this->positionMs() * 1000);
|
|
||||||
this->mPlaybackState = MprisPlaybackState::Playing;
|
|
||||||
} else if (status == "Paused") {
|
} else if (status == "Paused") {
|
||||||
this->pausedTime = QDateTime::currentDateTimeUtc();
|
this->pausedTime = QDateTime::currentDateTimeUtc();
|
||||||
this->mPlaybackState = MprisPlaybackState::Paused;
|
state = MprisPlaybackState::Paused;
|
||||||
} else if (status == "Stopped") {
|
} else if (status == "Stopped") {
|
||||||
this->mPlaybackState = MprisPlaybackState::Stopped;
|
state = MprisPlaybackState::Stopped;
|
||||||
} else {
|
} else {
|
||||||
this->mPlaybackState = MprisPlaybackState::Stopped;
|
state = MprisPlaybackState::Stopped;
|
||||||
qWarning() << "Received unexpected PlaybackStatus for" << this << status;
|
qWarning() << "Received unexpected PlaybackStatus for" << this << status;
|
||||||
}
|
}
|
||||||
|
|
||||||
emit this->playbackStateChanged();
|
if (state != this->mPlaybackState) {
|
||||||
|
// make sure we're in sync at least on play/pause. Some players don't automatically send this.
|
||||||
|
this->pPosition.update();
|
||||||
|
this->mPlaybackState = state;
|
||||||
|
emit this->playbackStateChanged();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MprisLoopState::Enum MprisPlayer::loopState() const { return this->mLoopState; }
|
MprisLoopState::Enum MprisPlayer::loopState() const { return this->mLoopState; }
|
||||||
|
|
Loading…
Reference in a new issue