How can I enable AirPlay on Raspberry Pi (Raspbian/Raspberry Pi OS)

I would like to use a Raspberry Pi 4 as an AirPlay speaker. Audio should be played back via HDMI or alternatively the headphone jack.

Problem: After a plain installation of Raspberry Pi OS the machine is not visible as AirPlay speaker because the necessary software is not installed.


Solution 1:

Open a terminal and enter:

sudo raspi-config

Then go to System Settings -> hostname and set a meaningful hostname. This will be the name of your AirPlay speaker on iPhones etc.

Then install AirPlay:

sudo apt-get install shairport-sync

The output is autodetected. When no HDMI is connected, the audio appears on the headphone jack.

In case you want to use the headphone jack, you may want to increase its volume because the default setting is quite low:

alsamixer

Then type S and then select headphones and then increase the volume all the way up to 100.

To make the volume persistent for the next reboot:

sudo alsactl store

AirPlay should be working now.