How to use Music Player Daemon

Updated on 28-May-2014
HIGHLIGHTS

Learn how to use Music Player Daemon or MPD as a way of network streaming, scrobbling and using your smartphone as a media remote

Your music is on your laptop but you want to play it on speakers connected to a desktop on the same network. How do you do this? Enter MPD.

MPD is a remarkably lightweight, fast and full featured music player with a client-server architecture. Using MPD, you can stream music or control playback to any other device on the same network. Music playback is controlled by the dozens of MPD clients out there (both graphical and console-based) that support nearly every major desktop and mobile OS, including Linux, Windows, OS X, Android, iOS, Symbian, Windows Mobile, Palm OS and and browser extensions.
Though MPD ports exist on Windows, they aren’t fully stable, so we recommend setting up the MPD server on a Linux machine. The client, of course can be any supported platform. Let’s get started!
Use MPD as a music player
This is a fairly trivial use for MPD, but an important one nonetheless, as it requires us to set up the server properly. To install MPD, issue one of the commands depending on your distribution:
• Ubuntu/Debian:  sudo apt-get install mpd
• Arch Linux:  sudo pacman -S mpd
• Fedora:  sudo yum install mpd
After the installation, MPD has to be configured with details of your music directory, playback options, sound outputs etc. MPD can be configured to run as a system service or on a per-user basis, and we’ll be choosing the latter, because it’s safer and more versatile. To get started, create the following files and folders in your home directory:
mkdir -p ~/.mpd{,/playlists}
touch ~/.mpd/{mpd.conf, mpd.db, mpd.pid, mpd.log, mpdstate}
Now copy the default configuration found in /usr/share/doc/mpd/example into the mpd.conf file we just created. This default config file is heavily documented and is thus very user-friendly. Open the file, uncomment and edit the following values:
• music_directory
“/path/to/music/folder”
• playlist_directory
      “/home/<username>/.mpd/playlists”
• db_file          
“/home/<username>/.mpd/mpd.db”
• log_file                
“/home/<username>/.mpd/mpd.log”
• pid_file
      “/home/<username>/.mpd/mpd.pid”
• state_file              
      “/home/<username>/.mpd/mpdstate”
Behaviour of symbolic links can be configured under the ‘Symbolic Link Behaviour’ section. You can also add a password to prevent unauthorized access. MPD can use multiple output devices simultaneously, including streaming over HTTPD. The default output device is usualy ALSA, so if you’re using ALSA as the default sound output device, no further configuration is required. However, if you’re using PulseAudio, simply uncomment the lines pertaining to PusleAudio. Similarly, to enable HTTP streaming, uncomment the relevant audio_output section. You can leave the port as the default (8000) unless you happen to be using it already, in which case change it to any other available port. Once you’ve set up the configuration file, stop the mpd daemon sudo service mpd stop and stop it from running as a system daemon:
Ubuntu: sudo update-rc.d mpd disable.
Ario is a graphical MPD client for Windows and Linux
Arch Linux: Make sure mpd is not present in the DAEMONS array of /etc/rc.conf
Then restart it by simply running ‘mpd’ as a non-root user. Unless you receive an error message, you have set up MPD correctly! To playback the music from MPD, you’ll need an MPD client. A full list of all the clients available can be viewed here – http://dgit.in/RtwpNI
Stream music on network
Streaming music over a local network (Wired / Wireless) is a fairly trivial affair once MPD has been set up as a server. If you just want to playback the music being broadcast by MPD, just enter the server computer’s IP address and the port used for HTTP streaming into a browser. For eg. If your host has an IP of 192.168.1.3 and if you’re using the default port 8000, just entering http://192.168.1.3:8000 into the address bar should
start playback.
If you want to control playback from the client machine, you’ll need an MPD client for the client OS. Ncmpcpp and PMS are two popular console-based MPD clients. Ario is a popular graphical MPD client that runs on Windows and Linux. Auremo (http://dgit.in/UoFPJ7) is a client for Windows that supports Windows 8 as well.
Use your smartphone as a media remote
Smartphone apps for iOS and Android not only let you stream your music over HTTP which is really handy, but they can also be used as media remotes to independently control music playback, search for songs and manage playlists.
MPDroid (http://dgit.in/OctuIr) is a free and fully featured MPD client, while MpoD is a native client for iOS devices (http://dgit.in/RtAeCB). To set up these apps, you’ll need to enter the details of both, the MPD server and the HTTP streaming server.
Scrobble Music to Last.fm
There are several ways to scrobble music played by MPD. Most MPD clients offer this feature, but our plugin of choice is called mpdscribble, which is a background process capable of sending data to both Last.fm and Libre.fm simultaneously. Install mpdscribble from the default repository for your distribution and edit the file /etc/mpdscribble.conf with your Last.fm login details. Next, activate the daemon by setting
MPD_SYSTEMWIDE=1 in the file /etc/default/mpdscribble. Restart the service with sudo service mpdscribble restart and your music should now be scrobbled flawlessly!
Playback music from Last.fm streams
MPD can also playback music from Last.fm streams, for which you’ll need to edit your ~/.mpd/mpd.conf and add the following section to it:
playlist_plugin {
name
“lastfm”
user
“lastfm_username”
password
“lastfm_password”
}
To start the playback, use the following command:
mpc load “lastfm://name/of/stream”
MPDroid can control playback and stream music from MPD

Connect On :