Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MPRIS Support #75

Closed
dweymouth opened this issue Mar 8, 2023 · 10 comments · Fixed by #219
Closed

MPRIS Support #75

dweymouth opened this issue Mar 8, 2023 · 10 comments · Fixed by #219
Labels
enhancement New feature or request
Milestone

Comments

@dweymouth
Copy link
Owner

No description provided.

@dweymouth dweymouth added the enhancement New feature or request label Mar 8, 2023
@dusnm
Copy link
Contributor

dusnm commented Apr 18, 2023

Since this project is using mpv as a music player backend, mpv actually has a plugin system and there just so happens to be a mpris plugin for mpv, available on most linux distributions. It can be an optional dependency of the program.

You can tell libmpv to load the plugin at startup by enabling the mpv config file loading, this will load all installed plugins as a side-effect. A bit too broad for my liking.

m.SetOptionString("config", "yes")

Alternatively you can load this plugin specifically, although this solution is quite inflexible

// The file path must be absolute
// mpv looks for plugins in
// 1. /etc/mps/scripts
// 2. ~/.config/mpv/scripts

m.SetPropertyString("scripts", "/etc/mpv/scripts/mpris.so")

I can confirm these work on Linux, but you'll need to figure out cross-platform support somehow.

Here's a screenshot of the controls showing up in Gnome's control center
Gnome control center showing MPRIS support

@dusnm
Copy link
Contributor

dusnm commented Apr 18, 2023

Forgot to mention, this will enable media keys as well. All working as expected. That's one solution for #56 at least on Linux.

@dweymouth
Copy link
Owner Author

Thanks for looking into this! Didn't know that MPV had a MPRIS plugin and this is a good short-term solution. But longer term I plan on implementing MPRIS directly in Supersonic. I am planning on changing the player backend to only load the current and next track into MPV's play queue, to make it easier to shuffle and reorder the play queue. This means that MPV won't know the full playlist and all seeking commands (prev, next, etc) have to flow through the PlaybackManager component.

The developer who added MPRIS to the STMP Subsonic client gladly agreed to move the MPRIS component to its own library for reuse in this project. (See: wildeyedskies/stmp#26) If anyone wanted to help the MPRIS effort along, finishing the implementation of that library and integrating it into Supersonic are the next steps. I'm sure @xxxserxxx would appreciate any help on the MPRIS library!

@dweymouth dweymouth added the help wanted Extra attention is needed label May 22, 2023
@dweymouth
Copy link
Owner Author

There is another possible MPRIS library https://github.com/quarckster/go-mpris-server. I haven't evaluated this yet but it looks promising.

@xxxserxxx
Copy link

There is another possible MPRIS library https://github.com/quarckster/go-mpris-server. I haven't evaluated this yet but it looks promising.

This looks really good. I'm going to re-implement my patch using this library and see how it works. This sort of interface is what I was driving for, and this library looks better than my hack.

@dweymouth dweymouth added this to the 0.5.0 milestone Jul 1, 2023
@dweymouth
Copy link
Owner Author

Just an update - I've done some experimenting with the quarckster/go-mpris-server library on the feature/mpris branch, and the media keys work but trying to call any of the event handler functions to export changed properties on pause, next track, etc, is crashing. Opened a bug report on the library with no response yet but if anyone wanted to test it out and debug (I am not really familiar at all with dbus) I'd really appreciate it!

@dweymouth dweymouth removed the help wanted Extra attention is needed label Jul 14, 2023
@dweymouth
Copy link
Owner Author

Issues with the upstream library are patched and MPRIS support will be in the next release!

@davidhaymond
Copy link
Contributor

@dweymouth Thank you so much, Drew! This is by far the one feature holding me back from making Supersonic my main Subsonic client.

@dweymouth dweymouth reopened this Jul 15, 2023
@dweymouth
Copy link
Owner Author

dweymouth commented Jul 15, 2023

Reopening because unfortunately emitting metadata on track change is broken :(

See quarckster/go-mpris-server#6

@dweymouth
Copy link
Owner Author

... and fixed in quarckster/go-mpris-server@c20bf18

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants