From f9fe3ad9a0fa89295e3b0a786505141cedb9254f Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Sat, 6 Apr 2024 14:52:13 -0400 Subject: [PATCH] Fix MPRIS seeking and SetPosition --- src/service/plugins/mpris.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/service/plugins/mpris.js b/src/service/plugins/mpris.js index 04651e143..fa7a4b7fe 100644 --- a/src/service/plugins/mpris.js +++ b/src/service/plugins/mpris.js @@ -242,11 +242,22 @@ var Plugin = GObject.registerClass({ player.Volume = packet.body.setVolume / 100; if (packet.body.hasOwnProperty('Seek')) - await player.Seek(packet.body.Seek * 1000); + await player.Seek(packet.body.Seek); if (packet.body.hasOwnProperty('SetPosition')) { - const offset = (packet.body.SetPosition * 1000) - player.Position; - await player.Seek(offset); + // We want to avoid implementing this as a seek operation, + // because some players seek a fixed amount for every + // seek request, only respecting the sign of the parameter. + // (Chrome, for example, will only seek ±5 seconds, regardless + // what value is passed to Seek().) + const position = packet.body.SetPosition; + const metadata = player.Metadata; + if (metadata.hasOwnProperty('mpris:trackid')) { + const trackId = metadata['mpris:trackid']; + await player.SetPosition(trackId, position * 1000); + } else { + await player.Seek(position * 1000 - player.Position); + } } // Information Request