How to Make MPD Work with AirPlay the Right Way

Some time ago I detailed a simple hack for making MPD work with AirPlay. I considered it just that, a simple hack. I wanted something better even then, and my recent revelation that MP3 sucks just made it all the more necessary. I also hated having to use iTunes for my special music. So at last I now present the best way I’ve found to make MPD work with AirPlay on the Mac.</p>

This solution won’t suit everyone. The command line client works best, in other words you do things by typing commands instead of navigating through menus. They do make an unmaintained Mac client but I haven’t played with that yet. You can also get clients for your iPhone, iPod, or iPad. It’ll also cost you $25. That said, it works beautifully.

First, you need to install MPD. If you haven’t already, install XCode and MacPorts. Once installed, go to the terminal and type “sudo port install mpd mpc”. Enter your administrator password and it will install the daemon and a command line utility called mpc which comes in handy if you need to debug this, which you will.

Now, create MPD’s configuration file. It comes with one in /opt/local/etc/mpd.conf, but I had to alter a few things. Either back that one up and overwrite it or just create a file called ~/.mpdconf. Put in the following contents:

</span>music_directory “~/Music”
playlist_directory “~/.mpd/playlists”
db_file “~/.mpd/database”
pid_file “~/.mpd/pid”
state_file “~/.mpd/state”
sticker_file “~/.mpd/sticker.sql”
port “6600”
auto_update “yes”
audio_output {
type “ao”
name “My Mac Device”
mixer_type “software”

Now create your user’s mpd directory by typing “mkdir ~/.mpd”. This should complete MPD’s setup.

This configuration file has some interesting features. It indexes your Music directory. Imagine iTunes without the mess of iTunes. It also uses the AO audio output. Once again comes to the rescue with their cross-platform audio library. The default Mac audio output jittered.

You should test your setup at this point. Type “mpd” at a terminal prompt and the daemon should start. It will index your music the first time you run it. Type “mpc” to see the status. Hopefully you will see something like this:

Updating DB (#1) …
volume: 100% repeat: off random: off single: off consume: off

If it can’t connect then something went wrong. Check that you’ve done everything properly so far.

You may want to have a look at MPD’s and MPC’s manual pages. Just type “man mpd” for the daemon and “man mpc” for the client. You will want to learn the client’s commands. Feel free to try adding some music or a radio stream with “mpc add” and playing it with “mpc play”. “mpc stop” stops playback. To kill the MPD process, just type “mpd –kill”. You should do this before moving on.

Assuming that worked, we can now move on to getting it working with AirPlay. You will need to download and purchase AirFoil. This awesome little program will pipe any audio over AirPlay. As a bonus, it will select the audio output to use. I love it!

Once you get it going you will want to tell it to launch MPD. This part tripped me up. I emailed their excellent tech support and they suggested using option-click and selecting MPD’s process. This works, but unfortunately VoiceOver doesn’t handle option-clicking very well. I had to find another solution.

I decided I had to get AirFoil to run MPD. I tried launching MPD directly but it wouldn’t work. Then I got the idea to make a wrapper script to launch MPD. I whipped one up but that wouldn’t work either. It turns out I had to turn the shell script into an application bundle. Fortunately, this awesome little utility called Appify does just that.

I used that program to convert my shell script to an application bundle and it works like a charm. Simply download this file and unzip it into your /Applications directory. Now choose MPD Launcher from AirFoil and there you go!

If you’ve followed everything then you should having a working MPD setup streaming its audio over AirPlay and over your chosen sound card. What a bargain! This really does provide the best of both worlds for those who like the command line but who also want AirPlay. You can also get mPoD for the iPhone/iPod and mPaD for the iPad, which will let you control this awesome setup from your iDevice. This gives a truly luxurious touch. You just can’t lose!