Saturday, 1 June 2013

Install Music Player Daemon on the Raspberry Pi

To play music on the Raspberry Pi, a music player is needed. A lot of people are using XBMC for that. I Personally prefer Music Player Daemon or just MPD. One way to install MPD on the Pi is simply to write sudo apt-get install mpd. This will however often install an older version. The best way to get the newest version is to compile it yourself from source. Head over to http://www.musicpd.org to download the newest stable version.

The easiest way to download it, is probably just to ssh into you Pi from a computer (if using Windows Putty is an excellent ssh client) and then write:
wget http://www.musicpd.org/download/mpd/stable/mpd-{version}.tar.gz

After download has completed, extract it using tar:
tar -zxvf mpd-{version}.tar.bz (or tar -jxvf mpd-{version}.tar.bz2)

Make sure that all the required libraries and build tools are installed. The INSTALL file has a list. If only MP3, FLAC and streaming support through the standard sound driver is needed, install required libraries by typing:
sudo apt-get install libboost-all-dev libasound2-dev libmad0-dev libid3tag0-dev libflac-dev libflac++-dev libglib2.0-dev libcurl4-openssl-dev libmms-dev

Now in the folder where the MPD source was extracted, configure, compile and install by typing:
./configure
make
sudo make install

Before starting MPD for the first time, MPD needs to be configured.

In home folder create a folder named .mpd (mkdir ~/.mpd).
Copy/rename doc/mpdconf.example from the MPD source directory to .mpd/mpd.conf (cp {mpd-source-location}/doc/mpdconf.example ~/.mpd/mpd.conf).
Then create a folder named playlists in the newly created .mpd folder (mkdir ~/.mpd/playlists).
Finally edit the .mpd/mpd.conf file and enable/changes the following settings.

music_directory            "/media/NAS/Music" #location of music
playlist_directory          "~/.mpd/playlists"
db_file                        "~/.mpd/database"
pid_file                       "~/.mpd/pid"
bind_to_address           "any"
audio_output {
        type                   "alsa"
        name                  "My ALSA Device"
        device                 "hw:1,0"           # Keep 0,0 if using the Pi analog audio
        format                "44100:16:2"
        mixer_type          "software"
        mixer_device       "default"
        mixer_control      "PCM"
        mixer_index        "0"
}

MPD can now be started by typing mpd in the terminal. To actually control MPD, a remote control is needed. Some can be found in Google Play and Apple App Store.

1 comment:

  1. This information is meaningful and magnificent, Which you have shared here about Music Player Daemon. I am impressed by the details that you have shared in this post and It reveals how nicely you understand this subject. Keep sharing this type of articles here. Music Player For Iphone

    ReplyDelete