Transform Raspberry Pi in an AirPlay with Shairport Server

Warning : This article has been automatically translated by Google Translate



Pour ceux qui ont des appareils iOS ou Mac OS à la maison il peut être intéressant de pouvoir diffuser de la musique sans devoir allumer toute une série d’appareil. C’est ce que nous allons faire en installant Shairport, un serveur Airplay, sur le Raspberry Pi.

Installer un serveur AirPlay avec Shairport

Le programme qui va nous permettre d’envoyer depuis nos appareils Apple de la musique a été fait James Laird grâce à du reverse engineering. Je vous passe les détails, mais si vous voulez plus d’infos, c’est ici.

  1. Installer les librairies pour pouvoir compiler Shaiport
    apt-get install git libao-dev libssl-dev libcrypt-openssl-rsa-perl libio-socket-inet6-perl libwww-perl avahi-utils cpanminus make avahi-daemon libavahi-client-dev
  2. Installer Net::SDP
    cpan Net::SDP
  3. Récupérer Shairport
    git clone https://github.com/albertz/shairport.git shairport
  4. Compiler et installer Shairport
    cd shairport
    make
    make install
  5. Copier le script de démarrage
    cp shairport.init.sample /etc/init.d/shairport
  6. Modifier le script /etc/init.d/shairport
    1. Changer la valeur de NAME par le nom que l’on souhaite faire apparaître dans les appareils Apple
    2. Changer la valeur de DAEMON avec l’emplacement de shairport si vous avez modifié l’emplacement par défaut
  7. Activer le script au démarrage du Raspberry Pi
    update-rc.d shairport defaults
  8. Un petit reboot et vous verrez apparaitre le serveur AirPlay

    Airplay via Shairport sur le Raspberry Pi Home Server

Si vous regardez en détail ce qui est installé, vous voyez que les services avachi-daemon et dbus accompagnent Shairport pour permettre de “voir” le Raspberry Pi Home Server depuis les différents appareils. Ca consomme un peu plus de mémoire :

Occupation mémoire des processus liés à Shairport, le serveur Airplay

15Mo de mémoire, c’est le prix à payer pour commander à distance votre nouvelle enceinte 😉

You may also like...

  • Max

    Hello

    The service works t - it for raspberry connected to Ethernet? not yet having wifi dongle I have followed your tutorial but I do not see the service on the phone.

    Thank you

  • Mathieu

    Max, Yes it works in ethernet.

    I know for my part, regardless of the service to install (shairport, nginx, transmission, vsftpd …) I even crossed sections of blogs.

    In the end I managed to install everything that I wanted.

    Note When even this blog has been the basis of my experience RPi, and I thank again Chris.

  • Max

    Thanks Mathieu with your response I could see that the problem just my numericable modem that filters the Hello between the lan and wlan Protocol so it is necessary that I see my network

  • silco

    Good evening I am the tutorial very understandable letter as usual (Congratulations again) but getting to the compile and install shairport time I type cd shairport and then I type make it tells me no found command ? I do not know what to do ? If someone just help me thank you.

    • Have you taken the step line 1 ? Because the make command is still in the list of packages to install …

  • silco

    Yes Yes

    my error is :

    make: CC: command no. found

    make: *** {ALAC.o} Error 127

    • Lack you the compiler. Bizarre. Try : apt - get install gcc

  • silco

    I install but ca still does not work but I also forgot to say something in my habit I do not have a pi raspberry but a cubieboard (http://cubieboard.org/) and distribution that runs top is linux linaro (lubuntu very ease) so I think that I have full package missing compared to moebius which is a shame I just try to use moebius but this doesnt so I reppart on linaro I would put the new error I have after installing the compiler. Thanks for the quick replies.

    • Actually there might be a dependency problem in the packages … See the next error

  • silco

    make: pkg-config: Command not found

    make: pkg-config: Command not found

    CC - O2 - Wall-c-o alac.o alac.c

    CC - O2 - Wall - DHAIRTUNES_STANDALONE hairtunes.c alac.o o hairtunes - lm - lpthread

    /tmp/ccsHsnEs.o: In function 'alac_decode':

    hairtunes.c:(.text 0x236): undefined reference to ' AES_cbc_encrypt’

    /tmp/ccsHsnEs.o: In function 'audio_thread_func':

    hairtunes.c:(.text 0xbfe): undefined reference to ' ao_play’

    /tmp/ccsHsnEs.o: In function 'hairtunes_init':

    hairtunes.c:(.text 0xd4e): undefined reference to ' AES_set_decrypt_key’

    hairtunes.c:(.text 0x1126): undefined reference to ' ao_initialize’

    hairtunes.c:(.text 0x1132): undefined reference to ' ao_driver_id’

    hairtunes.c:(.text 0x116a): undefined reference to ' ao_append_option’

    hairtunes.c:(.text 0x1174): undefined reference to ' ao_open_live’

    hairtunes.c:(.text 0x1186): undefined reference to ' ao_default_driver_id’

    hairtunes.c:(.text 0x119a): undefined reference to ' ao_append_option’

    hairtunes.c:(.text 0x11a6): undefined reference to ' ao_append_option’

    collect2: ld returned 1 exit status

    make: *** [hairtunes] Error 1

    • We must try to :

      apt - get install libao-dev

  • silco

    I got it made should I install avahi-daemon and libavahi-client-dev you say install in the tutorial on the time machine by stating that normally you must have already installed here but here it is not specified to install I believe, There are just avahi-utils installed.

    • Oops ! OK thanks for the clarification. I've updated to the article (step of installing packages)

  • Jerome pine

    Hello, small typo : When installing Net::SDP, to write “CPAN” instead of “cpanm” 😉

    • It's fixed, Thank you.

  • Someone has managed to install shairport as ArchLinuxArm ?

    • Have you tested to install it since AUR with yogurt ?

  • Christophe

    Hi Chris thanks for this tuto. I followed step-by-step your instructions for installation on ubuntu Server 10.04 the service appears well on the idevices but no sound…… I precise that the server once in place has neither keyboard nor display, I can therefore not me logger at startup. ya make it a service to enable ? Thank you in advance

    • Hello. Merci pour ton retour 😉
      Have you tried to activate the audio output of the Raspberry with the command : "amixer" cset numid = 3 1 ?

  • Christophe

    I'm not on raspberry, is that this command also works with a classic pc ?

    • It is necessary that Linux enables audio output. Not sure that this is done by default without any manipulation. If package alsa-tools (I think that's ca) is installed then the command can operate. Otherwise I have no idea.

  • Christophe

    It was that ! Finally in part…. ALSA-tools is not installed by default on ubuntu Server, but it was also necessary to load the module at startup, This page was very helpful to solve the problem. http://fluoblog.wordpress.com/2008/01/13/resolution-des-problemes-de-son-sous-ubuntu/ everything works now very fine.

    Thanks again for everything !!

  • Hello,

    I followed the tutorial on a normal Raspbian, but shairport does not appear in the list of servers on my Mac AirPort (or my Android) -I have an another Pi with RaspBMC who appears as well as the Freebox.

    Was a “PS - axf” I find:

    2074 ? SS 0:32 /usr/bin/dbus-daemon -System

    2110 ? S 0:00 avahi-daemon: running [Harajuku.local]

    2111 ? S 0:00 _ avahi-daemon: chroot helper

    avahi-daemon runs well (in the list of packages with apt - get install in the tutorial there is an error, “daemon” is spelled “deamon”) but I know what look to find the problem… If someone could help me…?

  • OK, found the problem actually, When I started shairport in manual I had the following error: “Can't locate Net / SDP.pm in @INC” I installed it by “sudo cpan install Net::SDP” and everything works. Merci pour ce tuto, and other !

  • I bought this sound card : http://www.amazon.co.uk/gp/product/B002FI7GWK/ref=oh_details_o03_s00_i00 (which is compatible with the Raspberry ft from the wiki). It works nickel, by making a small “aplay /usr/share/sounds/alsa/Front_Left.wav-D sysdefault” the sound works fine but of that I use AirPlay with, the music is accelerated. The sound is good but the music works faster. The indicator of iTunes remains at normal speed, and sometimes the music goes into pause to resume a few seconds after (as if the debit was not good enough). With the release of Raspberry Pi, AirPlay works super well, but I'd still like to slightly improve the quality with this low-cost card. An alternative to this music that runs fast ?

    Thank you ! =)

    GilDev

  • Alex5555

    Hello,

    Super tutorial, to start worldwide UNIX and RasPi !

    Small question, If like me you regret to have install (not the use finally) How to uninstall ?
    Thank you,

    • Hello,
      - To disable the service until the next reboot :
      Service shairport stop
      - Is to permanently disable the service :
      update - rc.d shairport remove
      - Either all uninstall (attention to the dependencies with other installed tools) :
      apt - get remove git libao-dev libssl-dev libcrypt-openssl-rsa-perl libio-socket-inet6-perl libwww-perl avahi-utils cpanminus make avahi-daemon libavahi-client-dev

      Hoping to help

      • Alex5555

        Thank you very much,
        Really thanks for your help and your pedagogy.

  • Amokriss

    Hello,
    Thank you for the tutorial, a part 2 explaining how to share a USB enclosure would be top! 🙂

    Otherwise there's a small typo in the first command line:
    avahi-daemon instead of avahi-daemon

    • C’est corrigé et merci pour l’idée de tuto 😉

  • Nico

    Hello,

    Can this tutorial also make the mirroring AirPlay ? Article speaks only of music apparently but can I streaming to this server RPI of video from the iOS Youtube app / / Browse all photos from my iPhone / start a game and see it live on TV ? (as it is possible to do this with the “AirMedia” in mirror of the Freebox Player mode ?)

    Thank you
    Nico

    • Not video with this app. Need to rPlay :

  • 0xgone

    Thank you for the tutorial !
    On my side the add-on Perl SDP auto install failed.
    I have the download it, compile it and install it with the command Build, only it me it was installing in
    my/home/pi/perl5 directory
    Suddenly I ended up copying the contents of/home/pi/perl5 handmade in/usr/share/perl5 and there finally
    the shairport.pl script found the module in the perl @INC path

  • Fabien

    Hello,
    I have install the all thanks for the tuto, par contre petit souci je trouve bien je nom du serveur airplay mais par contre aucun son ne sort par les enceintes 😮 … Can be a file a notify ?

Handpicked links

disk Page Caching using disk: enhanced Database Caching 129/509 queries in 1.376 seconds using disk Served from: pihomeserver.fr @ 2017-08-18 19:54:27 by W3 Total Cache -->