Music Player Daemon

From ArchWiki
Revision as of 09:48, 23 May 2008 by Angvp (talk | contribs) (MPD & Alsa)
Jump to: navigation, search

Template:I18n links start Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n links end

What is mpd?

mpd (Music Player Daemon) is an audio player that has a server-client architecture. mpd runs in the background as a daemon, manages playlists and a music database, and uses very few resources. In order to interface with it, you need a separate client. More information can be found on their website

Daemon Install Procedure

  • Sync and install with pacman
 pacman -S mpd

Configure mpd

  • Edit mpd.conf
  cp /etc/mpd.conf.example /etc/mpd.conf
  $EDITOR /etc/mpd.conf

To make audio output actually work ensure that you have setup audio card and mixer correctly. See /var/log/mpd/mpd.error if it still doesn't work.

When configuring the alsa or oss audio outputs, do not uncomment the 'device' or 'format' lines as this can cause problems with multiple sound playback. For example, this can prevent Mplayer from playing back sound while the mpd daemon is running, returning an audio error message stating the device is busy.

  • Create the mpd database. (this can take a while depending on the size of your collection):
 /etc/rc.d/mpd create-db
  • Start mpd
 /etc/rc.d/mpd start
  • Edit /etc/rc.conf and add mpd to the list of daemons to start on bootup.

Note: in case of permission problems when using ESD with mpd run this as root:

chsh -s /bin/true mpd


To get rid of timeouts (i.e. when you paused music for long time) in gpmc and other clients uncomment and increase connection_timeout option in mpd.conf.

If files and/or titles are shown in wrong encoding, uncomment and change filesystem_charset and id3v1_encoding options. Note that you cannot set encoding for ID3 v2 tags. To workaround this you may use external tag readers.

If you want to use another computer to control mpd over a network, the bind_to_address option in mpd.conf will need to be set to either your IP address, or any if your IP address changes frequently. Remember to add mpd to the /etc/hosts.allow file to enable external access.

Client Install Procedure

Install a client program for mpd. Popular options are:

mpc - Command Line Client (you'll probably want this one no matter what)

ncmpc - NCurses Client (this one is very handy for running in a console) Official Website of ncmpc

sonata - Python GTK+ Client Official Website of Sonata

gmpc - Gnome Client Official Website of gmpc

Install with

pacman -Sy mpc
pacman -Sy ncmpc
pacman -Sy sonata
pacman -Sy gmpc

Extra stuff scrobbling

To scrobble your songs to using MPD there are several alternatives. The easiest way, if you don't care about having to have a program window open all the time, is using Sonata which is a graphical frontend to MPD. It has built-in support for scrobbling in its preferences.

If you're not too keen on using Sonata (and having it open at all times) there is the very popular mpdscribble which acts as a background process which continuously fetches information about the status of MPD and quietly submits the information to MPD. It's fairly easy to configure and also easy to monitor using /var/log/mpdscribble.log.

MPD & Alsa

Sometimes, when you use other audio output, e.g: "some web with flash", mpd cannot reproduce anything anymore (until you restart)? God no!, the error looks something like: (if you search the file /var/log/mpd.error)

Error opening alsa device "hw:0,0": Device or resource busy

And here is the correct solution :D (dmix saving our life again), apply these lines in your /etc/mpd.conf

audio_output {
        type                    "alsa"
        name                    "Sound Card"
        options                 "dev=dmixer"
        device                  "plug:dmix"

And then restart with /etc/rc.d/mpd restart

Searching on Internet i found in Gentoo's wiki the reason for why that happens:

  • The sound card does not support hardware mixing (uses dmix plugin)
  • An application does not work with ALSA with it's default settings

So that error won't happening to everybody, just some people (like me) and you if that config works for you :-)

External links