I'm setting up Mopidy on Raspbian so I can use the Raspberry Pi as a Spotify (and local files) jukebox. I know the analog audio output of the Raspberry Pi is not great.

Is there a way to redirect all audio from the Raspberry Pi to an AirPlay device (an Airport Express, for example)?

It would be great if I could also do everything from the command line, so I could setup some scripts to switch different devices.

  • That is a great question. I love airplay and that just makes sense to use it on a Pi. Will dig around my self on that one but good question! +1
    – Piotr Kula
    Commented Mar 19, 2013 at 15:18
  • From what I understood, it can be done using PulseAudio. I'm digging around too.
    – leolobato
    Commented Mar 19, 2013 at 18:34
  • have a look at what we're discussing here raspberrypi.org/phpBB3/…
    – jmp909
    Commented Oct 4, 2013 at 13:25
  • I know this is a bit off-topic - but if you are not after remote playbac, what about some nice USB DAC?
    – petr
    Commented Oct 4, 2013 at 14:15

3 Answers 3


You could use mpd, pulseaudio and raop2 module, if necessary:

  • mpd for managing playlists, library, etc (sudo apt-get install mpd)
  • pulseaudio for managing audio outputs: raop for AirPlay, or any other output device such as analog jack, HDMI, http streaming service, etc (sudo apt-get install pulseaudio)
  • raop2 module for pulseaudio if the original raop module built into pulseaudio doesn't work

I had to build pulseaudio from source in order to get an updated version of the RAOP module for pulseaudio.

Here's what I did to make it work (it may complain about missing packages, just sudo apt-get install them):

Install MPD

sudo apt-get install mpd

Install PulseAudio

Choice A: you have an old AirPlay device, or you don't need UDP streaming.

It is easier but less compatible.

sudo apt-get install pulseaudio

Choice B: you want better compatibility, and support for both TCP and UDP streaming

Then you need raop2 module for pulseaudio, which means building PA from source.

Install git if you haven't already, and build pulseaudio (see official instructions):

sudo apt-get install git intltool autoconf build-essential
git clone https://github.com/hfujita/pulseaudio-raop2
cd pulseaudio-raop2
sudo make install

On my setup, I had to symlink libpulse.so.0 manually:

cd ~/pulseaudio-raop2
sudo rm /usr/lib/arm-linux-gnueabi/libpulse.so.0
sudo ln -s `cd;pwd`/pulseaudio-raop2/src/.libs/libpulse.so.0 /usr/lib/arm-linux-gnueabi/libpulse.so.0
sudo chown root.root /usr/lib/arm-linux-gnueabi/libpulse.so.0.16.2
sudo chmod 744 /usr/lib/arm-linux-gnueabi/libpulse.so.0

or, to your preference:

cd ~/pulseaudio-raop2
sudo rm /usr/lib/arm-linux-gnueabi/libpulse.so.0.16.2
sudo mv pulseaudio-raop2/src/.libs/libpulse.so.0 /usr/lib/arm-linux-gnueabi/libpulse.so.0.16.2
sudo chown root.root /usr/lib/arm-linux-gnueabi/libpulse.so.0.16.2
sudo chmod 744 /usr/lib/arm-linux-gnueabi/libpulse.so.0.16.2

Configure everything

MPD initial setup

Now we need to setup MPD:

sudo vi /etc/mpd.conf

In that file, set the following:

music_directory "/path/to/your/music"
user "mpd"
bind_to_address ""
bind_to_address "192.168.x.y"
bind_to_address "2a01:xzy....your IPv6 if you want"

We will need to edit the output, but we need the name of the pulseaudio sink first.

PulseAudio sinks

Avahi/zeroconf is nice to have because it will enable discovery of AirPlay devices (through zeroconf/mDNS/Bonjour):

sudo apt-get install avahi

Now we can start pulseaudio and try to load the RAOP modules:

pulseaudio --start --log-target=syslog -vvvv --log-level=debug
pacmd load-module module-raop-discover
pacmd list-sinks | grep name:

Here's the output on my setup:

name: <raop_output.Freebox-Player.local>
name: <raop_output.Freebox-Server.local>
name: <raop_output.Freebox-Player.local.2>
name: <raop_output.Freebox-Server.local.2>

You need then to edit /etc/mpd.conf again and add the following outputs:

audio_output {
    type            "pulse"
    name            "Freebox Player"
    sink            "raop_output.Freebox-Player.local"
    format          "44100:24:1"

Add one of these blocks for every AirPlay device that you wish to stream music to.

PulseAudio configuration

The last part is to setup PA:

sudo vi /etc/pulse/client.conf

Uncomment autospawn = yes, this will make pulseaudio start automatically when it is needed.

sudo vi /etc/pulse/default.pa

Add the following line at the bottom:

load-module module-raop-discover

This will make pulseaudio load the RAOP discover module when it is started.

Final step

It should be working now. Start MPD (stop it first if it's running):

sudo /etc/init.d/mpd start

Wait a little bit, it takes at least 10-15 seconds on my RasPI before the daemon can work properly.

Update your music library (and wait for it to finish):

sudo apt-get install mpc
mpc update

Enable outputs at will (the following will list the configured MPD outputs and enable the first one):

mpc outputs
mpc enable 1

Now use your favorite MPD client to play some music. I'm using ncmpcpp on command-line, and MPDroid on my phone/tablet.


Start mpd in verbose, pulseaudio with maximum logging level, and monitor logs:

mpd --verbose
pulseaudio --start --log-target=syslog --log-level=debug -vvvv
tail -f /var/log/mpd/mpd.log
tail -f /var/log/syslog

Try to make pulseaudio work first. Just load pulseaudio, load the RAOP discover module, list the sinks, setup the default sink and try to play something:

paplay /usr/share/sounds/alsa/Front_Center.wav

Once you have pulseaudio working, try and make MPD work with it.

  • 1
    That's exactly what I was looking for! I have a mopidy running on a Raspberry Pi. Will try this and update to tell you if it worked!
    – leolobato
    Commented Jul 13, 2014 at 1:25

Seem that pulseaudio-module-raop is what you're looking for. This guide has a detailed description on how to set this up in Ubuntu.

  • 1
    Generally speaking, an answer that provides detailed explanation is better than a link. Links can relocate or die. More importantly, explaining a little bit about pulseaudio-module-raop may be a good idea..
    – ramblinjan
    Commented Oct 23, 2013 at 5:47

Spent some time trying to configure Airplay through Raop/PulseAudio on the new Raspberry Pi 3 using Raspbian Jessie with very little success. I would highly recommend forked-daapd:

This is a much updated version of the original forked-daapd 0.19, a Linux/FreeBSD DAAP (iTunes) media server with support for AirPlay devices, Apple Remote (and compatibles), MPD, Spotify, mp3 streaming and internet radio.

Install was very straightforward and I had the whole thing up and running in about 10 minutes. Here are the install instructions as detailed here:

1a. If you use Jessie then add this line to /etc/apt/sources.list:
deb http://www.gyfgafguf.dk/raspbian jessie/armhf/
1b. If you use Wheezy then add this line to /etc/apt/sources.list:
deb http://www.gyfgafguf.dk/raspbian wheezy-backports/armhf/
2. Run sudo apt-get update and then sudo apt-get install forked-daapd
3. Edit the config file /etc/forked-daapd.conf and (re)start the server with sudo /etc/init.d/forked-daapd restart

Optional - how to add support for Spotify:
1. Add deb http://apt.mopidy.com/ stable main contrib non-free to /etc/apt/sources.list
2. Run sudo apt-get update and then sudo apt-get install libspotify-dev
3. Restart forked-daapd and enter credentials as described in the instructions.
4. Check the log to see how it is working. It should start loading your playlists.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.