Anyone who uses one (or more) Apple devices is certainly familiar with the AirPlay function. Thanks to this, media of all kinds can be streamed to other devices in the network. You can display photos on an AirPlay-enabled television, play videos or play music on AirPlay-enabled speakers.
At least the latter can be easily achieved with a RaspberryPi and thus convert a RaspberryPi into an AirPlay capable speaker.
I use this solution in my MagicMirror, for example. So you can use the RaspberryPi (which is built into the magicMirror) as a music speaker, too. 🙂
Everything you need to set up your RaspberryPi is described in the following article.
Inhalte
Safety instructions
I know the following hints are always a bit annoying and seem unnecessary. But unfortunately, many people who knew it "better" from carelessness lost their eyes, fingers or other things or hurt themselves. In comparison, a loss of data is almost not worth mentioning, but even these can be really annoying. Therefore, please take five minutes to read the safety instructions. Even the coolest project is worth no injury or other annoyance. https://www.nerdiy.de/en/sicherheitshinweise/
Affiliate links / advertising links
The links to online shops listed here are so-called affiliate links. If you click on such an affiliate link and shop via this link, Nerdiy.de receives a commission from the online shop or provider concerned. The price doesn't change for you. If you do your purchases via these links, you will support Nerdiy.de in being able to offer further useful projects in the future. 🙂
Requirements
Helpful Articles:
Before you start with this article, you should have prepared the RaspberryPi so that it can be reached via the network and controlled via SSH.
The following three articles describe what needs to be done to prepare the RaspberryPi:
RaspberryPi – Setup for nerdiys!
RaspberryPi – The first configuration!
RaspberryPi – Control the RaspberryPi via SSH
Required tools:
– none –
Required material:
Log in via SSH on the RaspberryPi
To get started, you first need to log in to RasPi with SSH on Putty. How to do it is described in the article

Update package management
The package management in Linux is a "central point" over which various software packages can be installed. For this to work reliably, the lists and sources of package management should be updated before installing any new packages.

sudo apt-get update && sudo apt-get upgrade



Install Shairport
The installation of Shairport is very easy thanks to the package manager.

Simply enter the following command into the console of your RaspberryPi.
sudo apt-get install shairport-sync

To start Shairport after the installation, you now have to execute the following command
sudo systemctl start shairport-sync
Show status
Thanks to the command line tool systemctl you can easily get an overview of the status of your Shairport server.

Simply enter the following command in the console of your RaspberryPi.
sudo systemctl status shairport-sync
Here you can now see whether the Shairport server is “active” or “inactive”.
Activate autostart
So that your Shairport server starts again automatically after a restart of the RaspberryPi, you should now activate its autostart.

Simply enter the following command into the console of your RaspberryPi.
sudo systemctl enable shairport-sync
Start music playback
That’s all. You should now be able to use your self-made AirPlay receiver on your iPhone (or other Apple device). 🙂

For example, you will now find the marked symbol in your “Podcasts” app.
As soon as you click on it …

… A menu should open in which the AirPlay speaker you just set up (called “MagicMirror” here) is displayed.
As soon as you click on it, music playback should start on it.
Have fun with the project
I hope everything worked as described. If not or you have any other questions or suggestions, please let me know in the comments. Also, ideas for new projects are always welcome. 🙂
P.S. Many of these projects - especially the hardware projects - cost a lot of time and money. Of course I do this because I enjoy it, but if you appreciate it that I share these information with you, I would be happy about a small donation to the coffee box. 🙂
Hi,
danke für den Artikel. Läuft!
Kleiner Hinweis: Du hast Paketverwaltung aktualisieren doppel drinne.
LG,
Flo
Hey Flo,
danke, freut mich. 🙂
Oh, danke für den Hinweis. Habe es korrigiert. 🙂
Beste Grüße
Fabian
Hallo, mein Name ist Achim Graf
Ich habe das Problem das sich Shairport-sync, ob auf dem Rapi 3b+ oder 4b, nicht mit Airmusic auf einen gerootetem Amazon Tablet verbindet. Airmusic auf dem Tablet findet den Raspi mit gestartetem Shairport-sync sofort aber wenn ich ihn verbinden will wird das Icon von Airmusic für 1 sec. blau, dann rot für 3-5 sec. und das Spiel geht von vorne los. Nach ca. 5 Durchläufen kommt eine Fehlermeldung mit Tips die ich schon mehrfach durch habe.
Raspian wurde jedesmal mit Raspberry Pi Imager neu aufgesetzt, alles wie beschrieben.
Airmusic verbindet sich sofort mit Shaiport4w auf dem Notbook und mit mit meinem Sony Android TV.
Ich bin an verzweifeln, es wär toll wenn du mir helfen könntest das an laufen zu bekommen.
Es läuft bei sooo vielen, was mache ich falsch.
Alles probiert mit der Desktop Version, der Lite Version, mit Wlan und mit Lan Kabel.
lg. A.Graf
Hi Achim,
so richtig kann ich mir da gerade keinen Reim drauf machen. (Auch weil ich Airmusic und co nicht nutze).
Aber es klingt ein bisschen danach als würde der Shairport client auf dem Raspi abstürzen und neu starten. Kannst du bitte mal das Journal (der logger output des Prozesses) checken und hier posten?
Du müsstest ihn mit folgendem Befehl anzeigen können “sudo journalctl -f -u shairport-sync”. Am besten das Journal starten und dann einen Verbindungsversuch starten. Vllt. kann man dort ja schon sehen was passiert ist. 🙂
Beste Grüße
Fabian
Hallo Fabian,
vielen lieben Dank das du dich der Sache annimmst.
Da ich so meine Probleme habe den Text aus dem Terminal zu übertragen schreibe ich ich in hier rein, er wiederholt sich 8x bis Airmusic aufgibt.
Es steht vor jeder Zeile der Raspi Name mit folgendem ” systemd[1]: ”
aber das ist wohl immer so.
Started Shaiport Sync – Airplay Audio Receiver.
shairport-sync.service: Main process exited, code=killed, status=11/SEGV
shairport-sync.service: Failed with result ´signal´.
shairport-sync.service: Consumed 3.099s CPU time.
shairport-sync.service: Scheduled restart job, restart counter is at 1.
Stopped Shairport Sync – Airplay Audio Receiver.
shairport-sync.service: Main process ex…………. das ganze wiederholt sich dann noch 7x.
Ich hoffe mal dass das aussagekräftig genug ist um den Fehler zu beheben.
Grüsse Achim
Hi Achim,
alles klar, das sieht danach aus als wäre meine anfängliche Vermutung bestätigt. Der Shairport service scheint abzustürzen wenn du einen Verbindungsversuch unternimmst.
Leider bekommt man mit dem aktuellen LogLevel keine richtige Aussage warum dies passiert. Also müssen wir das LogLevel erhöhen.
Dazu musst du die Service Datei etwas anpassen.
Gib dazu folgendes ein
sudo nano /lib/systemd/system/shairport-sync.service
und ändere die Zeile
ExecStart=/usr/bin/shairport-sync –daemon $DAEMON_ARGS
zu
ExecStart=/usr/bin/shairport-sync -vvv –daemon $DAEMON_ARGS
(Du musst also nur die “-vvv” hinzufügen.)
Führe dann bitte den folgenden Befehl aus um die Service Datei neu zu laden:
sudo systemctl daemon-reload
Nun solltest du wieder das Journal des shairport Service starten “sudo journalctl -f -u shairport-sync”.
Am besten öffnest du jetzt eine weitere SSH Verbindung/Terminal um dann den Shaiport Service mit “sudo systemctl restart shairport-sync” neu zu starten. Nun solltest du bereits mehr Informationen im Journal sehen.
Bitte versuch jetzt nochmal eine Verbindung zum Shairport Server herzustellen. Nun sollte die Ausgabe im Journal deutlich detaillierter sein.
Kopiere dann nochmal die Ausgabe des Journals hierhin. 🙂
(Wie man in putty text kopiert ist zum Beispiel auch hier beschrieben: https://www.alphr.com/copy-paste-putty/)
Beste Grüße
Fabian
// Inhalt .service Datei:
[Unit]
Description=Shairport Sync – AirPlay Audio Receiver
Documentation=man:shairport-sync(7)
Documentation=file:///usr/share/doc/shairport-sync/README.md.gz
Documentation=https://github.com/mikebrady/shairport-sync
After=sound.target
Requires=avahi-daemon.service
After=avahi-daemon.service
Wants=network-online.target
After=network.target network-online.target
[Service]
Type=simple
Restart=on-failure
EnvironmentFile=-/etc/default/shairport-sync
ExecStart=/usr/bin/shairport-sync $DAEMON_ARGS
User=shairport-sync
Group=shairport-sync
[Install]
WantedBy=multi-user.target
——————————————————————————
// Nach eingabe von -vvv aber ohne -daemon , da in original nicht vorhanden.
// ExecStart=/usr/bin/shairport-sync -vvv $DAEMON_ARGS
login as: guido
guido@192.168.188.47‘s password:
Linux Bestatt02 5.15.56-v7+ #1575 SMP Fri Jul 22 20:28:11 BST 2022 armv7l
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Wed Aug 17 10:25:33 2022
guido@Bestatt02:~ $ sudo nano /lib/systemd/system/shairport-sync.service
guido@Bestatt02:~ $ sudo journalctl -f -u shairport-sync // .service Datei bearbeitet.
guido@Bestatt02:~ $ sudo systemctl daemon-reload
— Journal begins at Mon 2022-04-04 14:05:58 CEST. —
Aug 17 10:25:33 Bestatt02 systemd[1]: Started Shairport Sync – AirPlay Audio Receiver.
Aug 17 10:25:33 Bestatt02 systemd[689]: shairport-sync.service: Failed to locate executable /usr/bin/shairport-sync-vvv: No such file or directory
Aug 17 10:25:33 Bestatt02 systemd[689]: shairport-sync.service: Failed at step EXEC spawning /usr/bin/shairport-sync-vvv: No such file or directory
Aug 17 10:25:33 Bestatt02 systemd[1]: shairport-sync.service: Main process exited, code=exited, status=203/EXEC
Aug 17 10:25:33 Bestatt02 systemd[1]: shairport-sync.service: Failed with result ‘exit-code’.
Aug 17 10:25:33 Bestatt02 systemd[1]: shairport-sync.service: Scheduled restart job, restart counter is at 5.
Aug 17 10:25:33 Bestatt02 systemd[1]: Stopped Shairport Sync – AirPlay Audio Receiver.
Aug 17 10:25:33 Bestatt02 systemd[1]: shairport-sync.service: Start request repeated too quickly.
Aug 17 10:25:33 Bestatt02 systemd[1]: shairport-sync.service: Failed with result ‘exit-code’.
Aug 17 10:25:33 Bestatt02 systemd[1]: Failed to start Shairport Sync – AirPlay Audio Receiver.
^C
guido@Bestatt02:~ $
// Neustart Raspi
—————————————————————————————————-
jetzt mit “-vvv –daemon”
guido@Bestatt02:~ $ sudo nano /lib/systemd/system/shairport-sync.service
guido@Bestatt02:~ $ sudo systemctl daemon-reload
guido@Bestatt02:~ $ sudo journalctl -f -u shairport-sync
— Journal begins at Mon 2022-04-04 14:05:58 CEST. —
Aug 17 10:25:33 Bestatt02 systemd[1]: Started Shairport Sync – AirPlay Audio Receiver.
Aug 17 10:25:33 Bestatt02 systemd[689]: shairport-sync.service: Failed to locate executable /usr/bin/shairport-sync-vvv: No such file or directory
Aug 17 10:25:33 Bestatt02 systemd[689]: shairport-sync.service: Failed at step EXEC spawning /usr/bin/shairport-sync-vvv: No such file or directory
Aug 17 10:25:33 Bestatt02 systemd[1]: shairport-sync.service: Main process exited, code=exited, status=203/EXEC
Aug 17 10:25:33 Bestatt02 systemd[1]: shairport-sync.service: Failed with result ‘exit-code’.
Aug 17 10:25:33 Bestatt02 systemd[1]: shairport-sync.service: Scheduled restart job, restart counter is at 5.
Aug 17 10:25:33 Bestatt02 systemd[1]: Stopped Shairport Sync – AirPlay Audio Receiver.
Aug 17 10:25:33 Bestatt02 systemd[1]: shairport-sync.service: Start request repeated too quickly.
Aug 17 10:25:33 Bestatt02 systemd[1]: shairport-sync.service: Failed with result ‘exit-code’.
Aug 17 10:25:33 Bestatt02 systemd[1]: Failed to start Shairport Sync – AirPlay Audio Receiver.
^C
guido@Bestatt02:~ $
// in nano den .service Teil nochmal geprüft, alles korrekt …hoffe ich.
[Service]
Type=simple
Restart=on-failure
EnvironmentFile=-/etc/default/shairport-sync
ExecStart=/usr/bin/shairport-sync -vvv -daemon $DAEMON_ARGS
User=shairport-sync
Group=shairport-sync
// selber Fehlermeldung
// Ich komme da nicht weiter
grüsse achim
Hi Achim,
das Problem liegt wohl daran, dass vor dem “-vvv” ein Leerzeichen fehlt.
In der Zeile “Aug 17 10:25:33 Bestatt02 systemd[689]: shairport-sync.service: Failed to locate executable /usr/bin/shairport-sync-vvv: No such file or directory”
kann man sehen, dass versucht wird den Befehl “shairport-sync-vvv” auszuführen. Der Parameter “-vvv” wird also als Teil des Dateinamens interpretiert und nicht als Parameter.
Bitte prüfe hier nochmal ob zwischen den Teilen “/usr/bin/shairport-sync” und “-vvv” auch wirklich ein Leerzeichen ist. 🙂
Beste Grüße
Fabian
Sorry, wollte mich noch ganz herzlich bedanken das du dir so viel Mühe gibts.
Leider scheint die Sache mit dem erweitertem Log bei mir nicht zu funzen, weiß nicht ob zu viele Leerzeichen drin sind, bin mit dem Syntax nicht so vertraut, versuche aber keine fehlerhaften Eingaben zu machen.
Dazu kommt, dass das Einstellen über reCaptcha ein graus ist. Ich weiß nie was der blöde Button unten rechts von mir will, funktioniert meistens erst beim 3 oder 4x und dann weiß ich nie warum es funktioniert hat …grrr.
Hallo Fabian, diese Seite ist eine Katastrophe.
Ich hab jetzt 3x versucht einen Text ab zu schicken was auch nach x Versuchen scheinbar funktioniert hat aber jedes mal wenn ich nach einigen Stunden die Seite aufrufe ist mein Kommentar verschwunden.
Das muss mit dem reCAPTCHA zusammen hängen, ich bekomme keine Aufforderung irgend einen Kram an zu klicken, Feuermelder, Fahrrad usw., Hoffentlich geht diese nicht auch wieder verloren. Wenn ich dir eine meiner Foren-email-Adressen schicke und wir diese über email gegen meine vernünftige tauschen, können wir dann darüber kommunizieren?
Nur wenn du noch Bock hast mir bei dem Problem zu helfen.
Gruß achim
Hi Achim,
die Seite funktioniert und deine Kommentare sind alle angekommen. Ich muss die einzelnen Kommentare aber jeweils freischalten.
Leider geht es nicht anders, da die Kommentarspalten täglich mehrmals von Spambots zugekleistert werden.
Ich versuche mir dein Problem im Laufe des Tages anzugucken.
Beste Grüße
Fab
Hi Fab,
neues Update, nachdem ich am letzten Wochenende auf ein Weinfest war und mir gleich Corona eingefangen habe brauchte ich eine Woche um wieder klar zu kommen.
Mit neuem Elan ans Werk gemacht und versucht das erweiterte Journal nochmal zu aktivieren.
Beide Raspis eingeschaltet und mit einem blöden Gesicht festgestellt das sich beide nach dem hochfahren sofort mit Airmusic auf dem Fire-Tablet verbunden haben.
Ohne Flaks, ich hab die Teile seit dem 18.08. nicht angerührt, sowas gibts doch garnicht oder?
Es ist schön das es funktioniert aber mich befriedigt das nicht weil ich nicht weis warum…
Will dich nicht weiter nerven mit dem mystischen tun der Raspis.
Vielen, vielen Dank für deine Geduld, du hast mir in der ganzen Zeit die Bestätigung gegeben das es doch irgendwann zum laufen kommt.
Allerdings hätte ich nicht gedacht das es einfach so klappt.
Wünsch dir eine schöne Zeit.
Grüsse Achim