spotifyd
spotifyd copied to clipboard
MPD client compatibility
Is it possible to control spotifyd with an MPD client? I have an Home Assistant setup and would like to control the music from there, even when guests connect to my spotifyd using Spotify Connect.
Hi!
I don't know anything about MPD other than that it exists, so I might not be the best person to answer here. :sweat_smile:
As far as I know, spotifyd
doesn't expose anything explicitly that would allow interaction from an MPD client. There are currently two ways in which the playback can be controlled:
- Spotify clients such as the official ones,
spotify-tui
,spotify-qt
, ... - The DBus MPRIS interface, which makes it controllable in most DEs and with tools like
playerctl
.
Maybe something can be written that uses the MPRIS interface to expose controls for MPD clients? What would be required for spotifyd
to support that natively? Would you be able to link any existing players that do this?
MPD is (also) a protocol that lets you control the player. I think a crate like this should be included to the spotifyd to provide an MPD interface.
disclaimer: I'm just interested in this feature, and picked up the best looking crate --at a first glance-- implementing MPD without any knowledge about it.
I know that for Mopidy exists a Mopidy-MPD server implementation. I'm looking for something similar. I know nothing about MPDs either unfortunately.
Thanks for the links to you both. Unfortunately, the crate you linked seems to only provide the necessary implementation details for clients and not for servers (which, I assume, we'd like to become). After some further search, I haven't yet been able to find a suitable server library (or even just something that would facilitate the process).
Given that there is already an interface to control spotifyd
, I'm personally not much in favour of adding another one to do more or less the same. Instead, what would be more suitable IMO are projects like this one, which – it seems – would allow exposing spotifyd
s MPRIS interface to MPD clients.
I hope you can somehow understand the implications of adding yet another control frontend, and why I'd rather recommend some existing solution that builds upon the existing one. :) Interested whether this (or something similar) would suit your use case!
clients and not for servers (which, I assume, we'd like to become) Oh, my bad.
Fixme, but MPRIS is a local thing as it uses DBUS. MPD exposes an interface to the network, so I could control the player from another device. That is what I used in the case of Mopidy. They are for different use cases.
Of course, spotify can be controlled from other clients (I do that myself).
I understand that, something like this has an implementation cost, but I thought if there was a well-maintained crate doing the job, it would only require to integrate it. It seems such a crate does not exist.
Fixme, but MPRIS is a local thing as it uses DBUS. MPD exposes an interface to the network, so I could control the player from another device. That is what I used in the case of Mopidy. They are for different use cases.
Yeah, I think I understand the differences in both protocols use cases. In what they control, they don't differ that much, however, so I thought that there had to be a project bridging these two protocols.
It seems that converting an MPD interface into MPRIS controls is quite easy (e.g. mpDris2 or mpd-mpris). The other way round (an MPD server exposing MPRIS controls) is understandably much less common, and I could only find the above-mentioned project (mpd-mpris-bridge).
I understand that, something like this has an implementation cost, but I thought if there was a well-maintained crate doing the job, it would only require to integrate it. It seems such a crate does not exist.
Given that there have already been several people upvoting and engaging in this issue, it seems that your use case isn't as niche as I thought at the beginning. I hope we can find a solution for this without having to make major changes to spotifyd
. Happy to read your thoughts and ideas on this!
Would be nice to properly be able to control spotifyd with eg. playerctl. Right now it only partly works. I feel like it's quite a common use-case? Not sure how it works though
Would be nice to properly be able to control spotifyd with eg. playerctl. Right now it only partly works. I feel like it's quite a common use-case? Not sure how it works though
That is already possible and works for me.
That is already possible and works for me.
Oh nice. I wonder why it didn't work for me then, hm. On the latest release, it works partially, but the latest commit it didn't work at all (playerctl couldn't even detect it as a player source).
I've also had no luck in using playerctl with spotifyd. If someone has some advice on how to setup this it would be appreciated. In my case also it says that no dbus source was detected. I've done all possible tests reading the related issues. Installed from source with the mpris flag, installed the full binary.
I tried it with the latest commit (c22b8194c5f660f1447d300bbf1b4917df882fde, cargo build --release --features "dbus_mpris"
) and it's working fine with playerctl
as well as with GNOME shell:
$ playerctl -l
spotifyd.instance26864
$ dbus-send --print-reply --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.ListNames | grep spotifyd
string "org.mpris.MediaPlayer2.spotifyd.instance26864"
$ dbus-send --print-reply=literal --dest=org.mpris.MediaPlayer2.spotifyd.instance26864 /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:org.mpris.MediaPlayer2.Player string:PlaybackStatus
variant Playing
Especially the last two commands might be helpful for debugging. (You just need to replace instance26864
with the value returned by the first command.)
I tried it with the latest commit (c22b819,
cargo build --release --features "dbus_mpris"
) and it's working fine withplayerctl
as well as with GNOME shell:$ playerctl -l spotifyd.instance26864 $ dbus-send --print-reply --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.ListNames | grep spotifyd string "org.mpris.MediaPlayer2.spotifyd.instance26864" $ dbus-send --print-reply=literal --dest=org.mpris.MediaPlayer2.spotifyd.instance26864 /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:org.mpris.MediaPlayer2.Player string:PlaybackStatus variant Playing
Especially the last two commands might be helpful for debugging. (You just need to replace
instance26864
with the value returned by the first command.)
Ohh sorry, I didn't realise I needed the dbus_mpris feature. It works now! Thank you. For some reason the latest commit tells me "no usable credentials found" even though they are in the keyring and the older version found them, but well that's another issue..
Good to hear. (Regarding your other problem: You might have to enable the dbus_keyring
flag as well.)
That did the trick indeed. Thanks a lot!