What is MPD?
Quoting from this article:
Music Player Daemon (MPD) allows remote access for playing music (MP3, Ogg Vorbis, FLAC, AAC, Mod, and wave files) and managing playlists. MPD is designed for integrating a computer into a stereo system that provides control for music playback over a local network. It is also makes a great desktop music player, especially if you are a console junkie, like frontend options, or restart X often.
In this post, I’ll be explaining how to get MPD up and running on Ubuntu (9.04). If you are working on some other platform, you can simply compile from source wherever applicable. Also, this post is mainly about using mpd as a desktop music player. The configuration part of it is common across distributions. So lets get started!
First, we need to install mpd.
sudo apt-get install mpd
Let us now configure it and get it up and running. You can either directly configure mpd for system-wide usage (/etc/mpd.conf) or you can configure it on a per user basis (~/.mpdconf).
sudo cp /etc/mpd.conf ~/.mpdconf
Before we edit our .mpdconf file, we need to create a few directories.
mkdir -p ~/.mpd/playlists
Now, re-define the following parameters to your .mpdconf file. (These will already be present in your file, just change the value in the quotes to shown values. I’ll explain the meaning of the options further on.)
music_directory is your music directory; and you probably don’t have all of your music in one directory. What we need to do is add symlinks to all the places where you do have your music files.
ln -s "path_to_music_1"
ln -s "path_to_music_2"
pid_file stores the pid of the running daemon. This is useful if you want to kill mpd, you only have to say
mpd --kill. The
db_file maintains your music database. The rest, I believe, is self-explanatory.
Okay, so we’re all set up now. Start mpd by typing mpd in the terminal.
mpd is now running. We will now build a database of our music for mpd to work with.
This will go through your music_directory and create your db_file.
Now all we need is a client to connect to the daemon. One of the more popular clients for mpd is gmpc, which is fancy to look at and comes with fancy plugins like last-fm scrobbler, lyricwiki, album covers from amazon etc. A good gmpc installation guide can be found here. However, I’m more of a console person, and I prefer to use ncmpc. This can be installed as follows:
sudo apt-get install ncmpc
I keep both gmpc as well as ncmpc on my machine, because sometimes I like to use gmpc for album covers, lyrics and jamendo/last.fm. Mostly though, I use ncmpc. ncmpc is unbelievably powerful. It is also so simple to use that I believe you will be able to figure it out all on your own. Just type ncmpc in the terminal!
*Update* As pointed out by gyllenbuste in the comments, you may have to allow mpd to follow symlinks depending on the distribution you are using. The mpd user should be a part of the plugdev group in order for mpd to follow symlinks over devices. Since this is always true in my case, I failed to write it down.