An idea I've had for a while is to write a proxy for MPD. I have mpd servers scattered around, and lots of clients I use on my laptop, and it was getting annoying to manually point each client at whatever server I was listening to at the time. The proxy would get in between the client and servers, and redirect all the clients to whatever server I told it to use.
One interesting question is whether the MPD protocol can deal with a client suddenly speaking to a different server with a different state. The protocol is mostly stateless, but the proxy would need to send the password each time it changed to a different server. There could also be trouble if clients cached info about the database, etc, as they wouldn't see the new info from the new server.
I bailed and took a quick and dirty workaround to that problem. My mpd proxy disconnect all clients when changing to a new host. Clients then reconnect, re-sending passwords, and clearing any caches.
So the implementation is not all it could be (and is not ready to be added to mpdtoys yet), but here it is: mpdproxy
Needs simpleproxy
installed to work, set MPD_PORT=6601
to make clients
use it, and to change the server it connects to, just echo foo >~/.mpdhost
.
I'm pretty happy with the result -- now I can use mpc
and
mpdtoys like mpstore
without worrying about specifying a host,
and sonata
lets me know what's playing everywhere.
On to pondering better things, like discovering nearby mpd servers automatically with mdns..