Nous allons voir comment installer MPD (Music Player Daemon) sur le raspberry pi.
MPD (Music Player Daemon) est un lecteur qui utilise une architecture client/serveur, ce qui permet de le contrôler à distance. De nombreux clients sont disponibles. Il reste néanmoins un lecteur de choix pour une machine de bureau, léger et efficace.
1. On met à jour la base de packages de raspbian
sudo apt-get update sudo apt-get upgrade
2. On installe les outils nécéssaires :
sudo apt-get install alsa-utils mpg321 lame
3. On vérifie si le module sonore est chargé, si pas on le charge :
sudo modprobe snd-bcm2835
4. On configure la sortie audio : On sélectionne la sortie audio que l'on veut utiliser. Pour cela on modifie le dernier chiffre par ce que l'on veut utiliser (0=auto, 1=analog, 2=HDMI).
sudo amixer cset numid=3 1
5. On installe le serveur mpd :
sudo apt-get install mpd
On change les droits sur le répertoire /var/lib/mpd et /var/rum/mpd
sudo chmod -R g+w,o+w /var/lib/mpd sudo chmod -R g+w /var/run/mpd
6. On édite le fichier de configuration /etc/mpd.conf
# Files and directories ####################################################### # # This setting controls the top directory which MPD will search to discover the # available audio files and add them to the daemon's online database. This # setting defaults to the XDG directory, otherwise the music directory will be # be disabled and audio files will only be accepted over ipc socket (using # file:// protocol) or streaming files over an accepted protocol. # music_directory "/var/lib/mpd/music" # # This setting sets the MPD internal playlist directory. The purpose of this # directory is storage for playlists created by MPD. The server will use # playlist files not created by the server but only if they are in the MPD # format. This setting defaults to playlist saving being disabled. # playlist_directory "/var/lib/mpd/playlists" # # This setting sets the location of the MPD database. This file is used to # load the database at server start up and store the database while the # server is not up. This setting defaults to disabled which will allow # MPD to accept files over ipc socket (using file:// protocol) or streaming # files over an accepted protocol. # db_file "/var/lib/mpd/tag_cache" # # These settings are the locations for the daemon log files for the daemon. # These logs are great for troubleshooting, depending on your log_level # settings. # # The special value "syslog" makes MPD use the local syslog daemon. This # setting defaults to logging to syslog, otherwise logging is disabled. # log_file "/var/log/mpd/mpd.log" # # This setting sets the location of the file which stores the process ID # for use of mpd --kill and some init scripts. This setting is disabled by # default and the pid file will not be stored. # pid_file "/var/run/mpd/pid" # # This setting sets the location of the file which contains information about # most variables to get MPD back into the same general shape it was in before # it was brought down. This setting is disabled by default and the server # state will be reset on server start up. # state_file "/var/lib/mpd/state" # # The location of the sticker database. This is a database which # manages dynamic information attached to songs. # sticker_file "/var/lib/mpd/sticker.sql" # ############################################################################### ... #bind_to_address "localhost" ...
7. On copie nos musiques sur le raspberry pi dans le répertoire /var/lib/mpd/music
8. On crée un fichier radio.m3u avec les radios que l'on veut pouvoir écouter par internet et on le copie dans /var/lib/mpd/playlists
#EXTM3U #EXTINF:-1,Pure FM http://broadcast.infomaniak.net:80/purefm-128.mp3 #EXTINF:-1,Classic 21 http://broadcast.infomaniak.net:80/classic21-128.mp3 #EXTINF:-1,Vivacité http://broadcast.infomaniak.net:80/vivabxl-128.mp3 #EXTINF:-1,Bel RTL http://audiostream.rtl.be/belrtl128 #EXTINF:-1,Contact FM http://radio-contact.ice.infomaniak.ch:80/radio-contact-high #EXTINF:-1,Nostalgie http://broadcast-adswizz.infomaniak.net:8000/nostalgiepremium-128.mp3 #EXTINF:-1,NRJ http://broadcast.infomaniak.net:80/nrjbe-high.mp3 #EXTINF:-1,Radio Contact http://audiostream.rtl.be/contactfr
On installe un client sur son pc et on peut écouter la musique qui se trouve sur son raspberry pi :
apt-get install gmpc
Nous allons installer un client web sur le serveur MPD. Cela permettra de piloter MPD via un navigateur web.
1. On install un serveur web
apt-get install nginx php-apc php5-fpm
2. On télécharge la dernière version de romprrompr.
3. On décompresse l'archive dans /var/www/
sudo mkdir www cd www sudo wget http://downloads.sourceforge.net/project/rompr/rompr-0.40.zip sudo unzip rompr-0.40.zip && sudo rm rompr-0.40.zip cd ..
4. On applique les bons droits sur le répertoire www et rompr.
chmod -R www-data:www-data www
5. On crée le fichier rompr de config pour nginx dans /etc/nginx/sites-available/.
server { listen 9191; root /var/www/rompr; index index.php; server_name raspberrypi; error_log /var/log/nginx/rompr_error.log; access_log /var/log/nginx/rompr_access.log; location ~ .php$ { include /etc/nginx/fastcgi_params; try_files $uri =404; fastcgi_index index.php; fastcgi_split_path_info ^(.+.php)(/.+)$; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_pass unix:/var/run/php5-fpm.sock; } }
6. On active le site.
sudo ln -s /etc/nginx/sites-available/rompr /etc/nginx/sites-enabled/rompr
7. On redémarre nginx.
sudo service nginx restart
8. On se connnecte sur l'application web (adresse_ip_du_raspberrypi:9191).