mirror of
https://git.outfoxxed.me/quickshell/quickshell.git
synced 2025-11-04 19:04:56 +11:00
service/mpris: make lengthSupported bindable and notify for changes
Fixes #109
This commit is contained in:
parent
71334bfcaf
commit
cee1f5837e
2 changed files with 7 additions and 6 deletions
|
|
@ -99,6 +99,8 @@ MprisPlayer::MprisPlayer(const QString& address, QObject* parent): QObject(paren
|
|||
} else return static_cast<qlonglong>(-1);
|
||||
});
|
||||
|
||||
this->bLengthSupported.setBinding([this]() { return this->bInternalLength != -1; });
|
||||
|
||||
this->bPlaybackState.setBinding([this]() {
|
||||
const auto& status = this->bpPlaybackStatus.value();
|
||||
|
||||
|
|
@ -258,21 +260,19 @@ void MprisPlayer::setPosition(qlonglong position) {
|
|||
}
|
||||
|
||||
void MprisPlayer::onExportedPositionChanged() {
|
||||
if (!this->lengthSupported()) emit this->lengthChanged();
|
||||
if (!this->bLengthSupported) emit this->lengthChanged();
|
||||
}
|
||||
|
||||
void MprisPlayer::onSeek(qlonglong time) { this->setPosition(time); }
|
||||
|
||||
qreal MprisPlayer::length() const {
|
||||
if (this->bInternalLength == -1) {
|
||||
if (!this->bLengthSupported) {
|
||||
return this->position(); // unsupported
|
||||
} else {
|
||||
return static_cast<qreal>(this->bInternalLength / 1000) / 1000; // NOLINT
|
||||
}
|
||||
}
|
||||
|
||||
bool MprisPlayer::lengthSupported() const { return this->bInternalLength != -1; }
|
||||
|
||||
bool MprisPlayer::volumeSupported() const { return this->pVolume.exists(); }
|
||||
|
||||
void MprisPlayer::setVolume(qreal volume) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue