Apple provides Airport Express to use the Airplay technology. But Airport Express is $99. Using Raspberry Pi we can use Airplay too. This makes it a $35 solution. You can buy Raspberry Pi from Element14.
But for this we will require quite a lot of prerequisites, scripts and a bit of command line coding. So let’s get started.
First we need to SSH to the Raspberry Pi. If you don’t know how to SSH, read this article.
Next we need to update and upgrade the packages. So run the below commands one by one. Both these commands may take around 5-20 minutes. So type the code and wait.
sudo apt-get update
sudo apt-get upgrade
By default the audio output comes from the HDMI out port. We need to change it to the Audio Out pin.
sudo amixer cset numid=3 1
Next we need to download the prerequisites for the various scripts we will use later.
sudo apt-get install git libao-dev libssl-dev libcrypt-openssl-rsa-perl libio-socket-inet6-perl libwww-perl avahi-utils libmodule-build-perl
Airplay uses SDP protocol. So we need to install the Perl Net SDP script.
git clone https://github.com/njh/perl-net-sdp.git perl-net-sdp
The above script has to be built, tested and then installed. Execute the following commands one by one.
sudo ./Build test
sudo ./Build install
Now we need to display that hey I have RPi available to play. So we use Shairport script.
git clone https://github.com/hendrikw82/shairport.git
The Shairport script will be executed using the commands given below.
./shairport.pl -a NameYourDevice
Replace NameYourDevice with the name that you want to display on your network. The script starts executing and its time to test the Airplay service on RPi.
However the Shairport script has to be executed every single time the Raspberry Pi boots. To avoid this we need Raspberry Pi to execute the script whenever it boots. To do this we need to write small set of code.
Before typing the code press Ctrl+C to exit the Shairport script. Now type the code below.
sudo make install
sudo cp shairport.init.sample /etc/init.d/shairport
sudo chmod a+x shairport
sudo update-rc.d shairport defaults
Final part is to give the device a name. So we edit the shairport file. I have named the device as RPi You can use your name.
sudo nano shairport
DAEMON_ARGS="-w $PIDFILE -a RPi”
To save the file press Ctrl+X. Now press Y and then press Enter.
Its time to exit the SSH. So type exit to release the connection.
Now its party time. Just connect the 3.5mm wire of speaker to Raspberry Pi and play your music loud.