dweymouth / supersonic

A lightweight and full-featured cross-platform desktop client for self-hosted music servers
GNU General Public License v3.0
670 stars 26 forks source link

fix: MPRIS Seek functionality on Linux #332

Closed adamantike closed 4 months ago

adamantike commented 4 months ago

Problem

The operating system toolbar's component to control Supersonic playback had its Seek functionality broken on Linux. When playing a song, seeking for a different position from Supersonic worked as expected, but seeking from the toolbar did nothing to the current track.

I found that the underlying reason was in MPRISHandler.SetPosition, as the if m.curTrackPath == trackId always returned false.

m.curTrackPath was the right value, but trackId was wrong: On the first song being played for a tracklist, trackId when trying to seek was set to /org/mpris/MediaPlayer2/TrackList/NoTrack. When moving to the next song, trackId then became the Track ID of the previously played song.

Solution

Changing the call to OnTitle() is enough to fix the issue, as the MPRIS Metadata() generation depends on the value of m.curTrackPath. Because it was being called before changing its value, the received trackId was always off.