Apple’s AirPlay is an incredibly useful feature – assuming, of course, that you have enough Apple products to make it work. As you probably know, AirPlay allows you to sling from an Apple device to another device. But while Apple has been a little nicer than usual about licensing the tech out to third-party companies, there’s still a good chance that your particular stereo isn’t AirPlay-capable. That’s too bad, but its’ a problem you can solve with – you guessed it – a Raspberry Pi. You can actually make a Raspberry Pi AirPlay receiver with nothing more than a few commands in Terminal. Plug that Raspberry Pi into your TV with an HDMI cable, and bingo: you’re ready to rock, and all without having to buy an Apple TV. The only catch is that this receiver is audio-only. Ready to check it out? Here’s how to set up a Raspberry Pi AirPlay receiver.
How to set up a Raspberry Pi AirPlay receiver
You don’t need any special equipment for this project – all we’re going to do is build and install an AirPlay audio player called Shairport Sync. We’re going to start with Raspbian installed (if you haven’t done this yet, check out our piece on how to install Raspbian on the Raspberry Pi).
Step 1: Check for updates
Assuming you’ve already got Raspbian installed, let’s just get on the same page here by making sure everything is up-to-date.
Open Terminal and run the following commands:
sudo apt-get update sudo apt-get upgrade
Great, good as new. Moving on!
Step 2: Install the necessary packages
We need a few packages to make this work. Let’s get them!
sudo apt-get install autoconf automake avahi-daemon build-essential git libasound2-dev libavahi-client-dev libconfig-dev libdaemon-dev libpopt-dev libssl-dev libtool xmltoman
Okay, so maybe that’s more than “a few.” All of those things after “install” are individual packages that our Shairport Sync build will rely on. Some are libraries, which will allow Shairport Sync to perform different tasks. Others are tools that will be used in our build process down in Step 4.
Step 3: Clone the Shairport Sync repository
As mentioned earlier, Shairport Sync is the star of this show. So, naturally, we’ll need the Shairport Sync repository. It’s over on GitHub, but we want it on our Raspberry Pi, so let’s clone it – or, in other words, let’s make a local copy of the repository on the Raspberry Pi. To do this, we’ll just use a line in Terminal:
git clone https://github.com/mikebrady/shairport-sync.git
Step 4: Build and install Shairport Sync
Now we have our own version of the Shairport Sync repository on our Pi, but we still need to build and install it. But before we can do that, we need to be in the right directory:
Now it’s time to get building. Enter these two commands in Terminal:
autoreconf -i -f ./configure --with-alsa --with-avahi --with-ssl=openssl --with-systemd --with-metadata
Why all the dashes and “with” things? They tell us what our Shairport Sync build will support. Our new build supports Advanced Linux Sound Architecture (ALSA) (–with-alsa). It also supports Avahi, a system-wide zero-configuration (zeroconf) networking service (–with-avahi) and OpenSSL encryption (–with-ssl).
On top of that, we’ve added support for Shairport Sync to be launched automatically on boot (–with-systemd) and gave Shairport Sync the power to pipe metadata to compatible applications (–with-metadata).
These particular options aren’t the only ones you can tack onto your build. For more about all the different things your Shairport Sync build could support, check out the Shairport Sync GitHub page.
With the build system prepared, we can move to compiling and installing Shairport Sync. Fortunately, this is requires a much quicker couple lines of code:
make sudo make install
Now we have Shairport Sync!
Step 5: Enable Shairport Sync to start on boot
We’re almost set here – just one last step. Shairport Sync will make your Raspberry Pi an AirPlay receiver, but it won’t be very convenient if you have to start Shairport Sync on your Raspberry Pi before you can use the feature. So let’s just have Shairport Sync start up automatically when you Pi boots up.
We added support for this feature in our build (–with-systemd, remember?), but we still have to turn the feature on. To enable Shairport Sync to start automatically on boot, run the following command:
sudo systemctl enable shairport-sync
Your Raspberry Pi will now be AirPlay-ready from the moment it boots. But you don’t have to reboot to get Shairport Sync running right now (though that would work) – you can just use another Terminal command:
sudo service shairport-sync start
That’s it! Your Raspberry Pi AirPlay receiver should be all set. To confirm that it works, hop on an Apple device and head to the AirPlay menu or to System Preferences>Sound. Your Raspberry Pi should be on the list, ready to receive AirPlay casts!