From d8cdea9c9b96ff04021064264d954b287cb0959f Mon Sep 17 00:00:00 2001 From: Bart De Vries Date: Fri, 12 May 2023 16:25:37 +0200 Subject: [PATCH] Add support for MPRIS playback rate This will ensure that the playback position can be accurately extrapolated for playback rates other than 1.0. --- plugins/mpriscontrol/mpriscontrolplugin.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/plugins/mpriscontrol/mpriscontrolplugin.cpp b/plugins/mpriscontrol/mpriscontrolplugin.cpp index 86bc57189..ec02b72d7 100644 --- a/plugins/mpriscontrol/mpriscontrolplugin.cpp +++ b/plugins/mpriscontrol/mpriscontrolplugin.cpp @@ -163,6 +163,10 @@ void MprisControlPlugin::propertiesChanged(const QString &propertyInterface, con np.set(QStringLiteral("loopStatus"), properties[QStringLiteral("LoopStatus")]); somethingToSend = true; } + if (properties.contains(QStringLiteral("Rate"))) { + np.set(QStringLiteral("rate"), properties[QStringLiteral("Rate")].toDouble()); + somethingToSend = true; + } if (properties.contains(QStringLiteral("Shuffle"))) { np.set(QStringLiteral("shuffle"), properties[QStringLiteral("Shuffle")].toBool()); somethingToSend = true; @@ -293,6 +297,11 @@ bool MprisControlPlugin::receivePacket(const NetworkPacket &np) qCDebug(KDECONNECT_PLUGIN_MPRIS) << "Setting loopStatus" << loopStatus << "to" << serviceName; mprisInterface.setLoopStatus(loopStatus); } + if (np.has(QStringLiteral("setRate"))) { + double rate = np.get(QStringLiteral("setRate")); + qCDebug(KDECONNECT_PLUGIN_MPRIS) << "Setting rate" << rate << "to" << serviceName; + mprisInterface.setRate(rate); + } if (np.has(QStringLiteral("setShuffle"))) { bool shuffle = np.get(QStringLiteral("setShuffle")); qCDebug(KDECONNECT_PLUGIN_MPRIS) << "Setting shuffle" << shuffle << "to" << serviceName; @@ -334,6 +343,7 @@ bool MprisControlPlugin::receivePacket(const NetworkPacket &np) answer.set(QStringLiteral("canGoNext"), mprisInterface.canGoNext()); answer.set(QStringLiteral("canGoPrevious"), mprisInterface.canGoPrevious()); answer.set(QStringLiteral("canSeek"), mprisInterface.canSeek()); + answer.set(QStringLiteral("rate"), mprisInterface.rate()); // LoopStatus is an optional field if (mprisInterface.property("LoopStatus").isValid()) {