MPD through a bluetooth speaker
UPDATE! Check out my latest post on MPD to see an updated writeup on my MPD setup and usage.
It's also worth mentioning that since I published this and the updated entry, I've stopped using a Bluetooth speaker with MPD. There were just too many issues with reliability and "lag" that I now connect my bluetooth speaker with an audio cable. A fair warning for those that want to go down this path.
I recently grabbed a bluetooth speaker, intending to mostly use it with my phone, but I quickly found myself wanting to play my laptop's MPD through it. Today I'll describe how I got it going - and In the process we'll also resolve some issues with the setup described in my other MPD post. The process was pretty straight forward but it didn't just work so I figured I would talk about it a bit here.
→ The speakers
I'm really not sure how much this varies from speaker to speaker, but I imagine not much. At any rate nothing special had to be done with the speaker; Just switch it on and connect it to your machine (I use
blueman-applet, personally.) Aside from this I don't have anything particular to say about the speakers (and I don't think it's important to mention the brand I have.)
→ The config
Now you've got speakers that are connected, but no sound comes out (from MPD.) You'll likely need to tweak MPD and Pulseaudio (assuming you are using the latter...) to remedy this situation.
This is the easy part; we just need to make sure that MPD connects to a Pulseaudio stream on
localhost. The explanation is not so simple, and is best explained here, but the short version is that since Pulseaudio is running in a user (not system) session, our system MPD needs to talk to Pulse this way. Add this to your
Then, restart MPD.
You are using Pulseaudio, right? It's OK if not but I'm afraid the following won't apply to you. To ensure that your user session of Pulseaudio can be reached by MPD an ACL rule needs to be added for TCP communication on
localhost. One can do that with this command:
# Run this as your unprivileged login user
$ pacmd load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1
Or, this can be set globally in the
→ On MPD and Pulseaudio...
I had previously talked about setting up MPD for use as one's primary music player. One relatively major caveat which I did not mention in that post was how, when set up as I described, MPD would not utilize Pulseaudio as it was intended; it would instead try to work as if the connection was ALSA.
What this means is that MPD, when running, would not be just another audio stream handled by Pulseaudio. Not only that, but it would actively clobber or be clobbered by other "real" Pulseaudio streams. This manifests itself in the form of other audio not working while MPD is running, or MPD not running while other audio is running. Definitely annoying but somewhat manageable...
But now.. with the above tweaks to Pulseaudio and MPD, it now acts like a normal Pulseaudio stream! This means it can play alongside other audio streams and will generally behave just like you expect it to. Pretty awesome!
So there you have it - we've not only hooked up MPD to some bluetooth speakers but we also solved a nagging configuration issue with it! Nothing too terribly crazy but it didn't work out of the box and did take a bit of searching to arrive at the (somewhat obscure for non-Pulseaudio experts) solution. Cheers to not using a GUI music player!