Skip to content

Commit

Permalink
Fix MPRIS seeking and SetPosition
Browse files Browse the repository at this point in the history
  • Loading branch information
ferdnyc committed Apr 6, 2024
1 parent 9d27463 commit f9fe3ad
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/service/plugins/mpris.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f9fe3ad

Please sign in to comment.