Difference between revisions of "Music Player Daemon"

From ArchWiki
Jump to: navigation, search
m (Global Configuration)
m (Local configuration (per user): add sticker_file conf for completeness)
(6 intermediate revisions by 6 users not shown)
Line 19: Line 19:
 
{{Article summary end}}
 
{{Article summary end}}
  
'''[http://mpd.wikia.com MPD]''' ('''m'''usic '''p'''layer '''d'''aemon) is an audio player that has a server-client architecture.  It plays audio files, organizes playlists and maintains a music database all while using  very few resources. In order to interface with it, a separate [[#Clients|client]] is needed.
+
'''[http://www.musicpd.org/ MPD]''' ('''m'''usic '''p'''layer '''d'''aemon) is an audio player that has a server-client architecture.  It plays audio files, organizes playlists and maintains a music database all while using  very few resources. In order to interface with it, a separate [[#Clients|client]] is needed.
  
 
== Installation ==
 
== Installation ==
=== Stable version ===
+
 
 
The latest stable version of {{Pkg|mpd}} is available in the [[official repositories]].
 
The latest stable version of {{Pkg|mpd}} is available in the [[official repositories]].
  
=== Git version ===
 
 
Should users wish to run an experimental version, the [[AUR]] offers several from which to choose. For example, {{AUR|mpd-git}}.
 
Should users wish to run an experimental version, the [[AUR]] offers several from which to choose. For example, {{AUR|mpd-git}}.
  
Line 35: Line 34:
  
 
* mpd.db - The music database
 
* mpd.db - The music database
* mpd.pid -  The file where mpd stores its process ID
+
* pid -  The file where mpd stores its process ID
 
* mpd.log - mpd logs here
 
* mpd.log - mpd logs here
 
* mpdstate - mpd's current state is noted here
 
* mpdstate - mpd's current state is noted here
Line 42: Line 41:
 
In order for MPD to be able to play back audio, [[ALSA]], [[PulseAudio]] or [[OSS]] needs to be setup and working.
 
In order for MPD to be able to play back audio, [[ALSA]], [[PulseAudio]] or [[OSS]] needs to be setup and working.
  
=== Local Configuration (per user) ===
+
=== Local configuration (per user) ===
  
 
MPD can be configured per user (rather than the typical method of configuring MPD globally).  Running MPD as a normal user has the benefits of:
 
MPD can be configured per user (rather than the typical method of configuring MPD globally).  Running MPD as a normal user has the benefits of:
Line 51: Line 50:
 
To setup: create a directory for the required files and the playlists; copy the example configuration locally; create all of the requisite files:
 
To setup: create a directory for the required files and the playlists; copy the example configuration locally; create all of the requisite files:
  
  mkdir -p ~/.mpd/playlists
+
  $ mkdir -p ~/.mpd/playlists
  cp /usr/share/doc/mpd/mpdconf.example ~/.mpd/mpd.conf
+
  $ cp /usr/share/doc/mpd/mpdconf.example ~/.mpd/mpd.conf
  touch ~/.mpd/{database,log,state}
+
  $ touch ~/.mpd/{database,log,state,pid}
  
 
Edit {{ic|~/.mpd/mpd.conf}} and specify the requisite files:
 
Edit {{ic|~/.mpd/mpd.conf}} and specify the requisite files:
Line 64: Line 63:
 
pid_file          "~/.mpd/pid"
 
pid_file          "~/.mpd/pid"
 
state_file        "~/.mpd/state"
 
state_file        "~/.mpd/state"
 +
sticker_file      "~/.mpd/sticker.sql"
 
}}
 
}}
  
Line 73: Line 73:
  
 
  # MPD daemon start (if no other user instance exists)
 
  # MPD daemon start (if no other user instance exists)
  [ ! -s ~/.mpd/mpd.pid ] && mpd
+
  [ ! -s ~/.mpd/pid ] && mpd
  
 
To start with the X.org server add to either [[xprofile]] or [[xinitrc]].  Some DEs ignore these files (GNOME does) and a desktop file must be placed in {{ic|~/.config/autostart/mpd.desktop}}:
 
To start with the X.org server add to either [[xprofile]] or [[xinitrc]].  Some DEs ignore these files (GNOME does) and a desktop file must be placed in {{ic|~/.config/autostart/mpd.desktop}}:
  
<pre>[Desktop Entry]
+
{{bc|<nowiki>
 +
[Desktop Entry]
 
Encoding=UTF-8
 
Encoding=UTF-8
 
Type=Application
 
Type=Application
Line 86: Line 87:
 
Terminal=false
 
Terminal=false
 
Hidden=false
 
Hidden=false
X-GNOME-Autostart-enabled=false</pre>
+
X-GNOME-Autostart-enabled=false
 +
</nowiki>}}
  
 
==== Autostart with systemd ====
 
==== Autostart with systemd ====
Line 96: Line 98:
 
* Start user-session service (e.g. {{ic|sudo systemctl enable user-session@USERNAME}}).
 
* Start user-session service (e.g. {{ic|sudo systemctl enable user-session@USERNAME}}).
 
* Add local service file {{ic|~/.config/systemd/user/mpd.service}} (see below).
 
* Add local service file {{ic|~/.config/systemd/user/mpd.service}} (see below).
* Start local systemd {{ic|systemd --user &}}; enable service file {{ic|systemctl --user enable mpd}}; start it {{ic|systemctl --user start  mpd}}.
+
* Start local systemd {{ic|/usr/lib/systemd/systemd --user &}}; enable service file {{ic|systemctl --user enable mpd}}; start it {{ic|systemctl --user start  mpd}}.
* Add {{ic|systemd --user &}} to {{ic|~/.profile}} or another autostart file.
+
* Add {{ic|/usr/lib/systemd/systemd --user &}} to {{ic|~/.profile}} or another autostart file.
 
* Reboot and MPD start.
 
* Reboot and MPD start.
  
<pre>[Unit]
+
{{bc|<nowiki>
 +
[Unit]
 
Description=Music Player Daemon
 
Description=Music Player Daemon
  
Line 108: Line 111:
  
 
[Install]
 
[Install]
WantedBy=default.target</pre>
+
WantedBy=default.target
 +
</nowiki>}}
  
 
'''Current setup''' (this hasn't worked for everybody)
 
'''Current setup''' (this hasn't worked for everybody)
Line 115: Line 119:
 
We will NOT use the {{ic|/usr/lib/systemd/system/mpd.service}} which is intended to start the mpd.service as root and for all users.  
 
We will NOT use the {{ic|/usr/lib/systemd/system/mpd.service}} which is intended to start the mpd.service as root and for all users.  
  
{{Note|It is recommended to follow the instructions in the [[Systemd/User]] page fully, and to have your whole session managed by {{ic|systemd --user}}.}}
+
{{Note|It is recommended to follow the instructions in the [[Systemd/User]] page fully, and to have your whole session managed by {{ic|/usr/lib/systemd/systemd --user}}.}}
  
If you already enabled it, just disable it first:
+
If you already enabled it, just disable it first.
{{bc| # systemctl disable mpd.service}}
+
  
 
If you used to start mpd inside your {{ic|~/.xinitrc}}, comment or delete the line
 
If you used to start mpd inside your {{ic|~/.xinitrc}}, comment or delete the line
{{bc|mpd ~/.mpdconf}}
+
mpd ~/.mpdconf
  
 
Then, edit a new file ~/.config/systemd/user/mpd.service  
 
Then, edit a new file ~/.config/systemd/user/mpd.service  
Line 139: Line 142:
 
{{hc|~/.xinitrc|
 
{{hc|~/.xinitrc|
 
#run systemd as user instance
 
#run systemd as user instance
systemd --user &
+
/usr/lib/systemd/systemd --user &
 
}}
 
}}
  
 
Log out, log in your xsession.
 
Log out, log in your xsession.
 
Let's first check mpd is not running. If yes, just kill it. If not, continue to the next step.
 
Let's first check mpd is not running. If yes, just kill it. If not, continue to the next step.
{{bc|$ ps -ef &#124; grep mpd}}
+
$ ps -ef | grep mpd
  
 
Now, enable and start mpd.service as per user  
 
Now, enable and start mpd.service as per user  
Line 151: Line 154:
  
 
Check the mpd status and see if mpd.service is correctly enabled and started
 
Check the mpd status and see if mpd.service is correctly enabled and started
{{bc|$ systemctl --user status mpd}}
+
$ systemctl --user status mpd
  
==== Scripted Configuration ====
+
==== Scripted configuration ====
Rasi has written a script that will create the proper directory structure, configuration files and prompt for the location of the user's Music directory; it can be downloaded [http://53280.de/dl/mpdsetup.tar here].
+
 
 +
Rasi has written a script that will create the proper directory structure, configuration files and prompt for the location of the user's Music directory; it can be downloaded [http://53280.de/dl/mpdsetup.sh here].
 +
 
 +
=== Global configuration ===
  
=== Global Configuration ===
 
 
{{Warning|Users of PulseAudio with a local mpd have to implement a [[Music Player Daemon/Tips and Tricks#Local (with separate mpd user)|workaround]] in order to run mpd as its own user!}}
 
{{Warning|Users of PulseAudio with a local mpd have to implement a [[Music Player Daemon/Tips and Tricks#Local (with separate mpd user)|workaround]] in order to run mpd as its own user!}}
  
Line 176: Line 181:
  
 
==== Music directory ====
 
==== Music directory ====
 +
 
MPD needs to have {{ic|+x}} permissions on ''all'' parent directories to the music collection (ie. if it's located outside of {{ic|/var/lib/mpd}}). Thus users will most likely need to remount the music directory under a directory that mpd has access to -- this only applies if running as the 'mpd' user.
 
MPD needs to have {{ic|+x}} permissions on ''all'' parent directories to the music collection (ie. if it's located outside of {{ic|/var/lib/mpd}}). Thus users will most likely need to remount the music directory under a directory that mpd has access to -- this only applies if running as the 'mpd' user.
  
Line 190: Line 196:
  
 
==== Start MPD ====
 
==== Start MPD ====
 +
 
MPD can be controlled with the ''mpd'' [[daemon]]. The first startup can take some time as MPD will scan your music directory.
 
MPD can be controlled with the ''mpd'' [[daemon]]. The first startup can take some time as MPD will scan your music directory.
  
Line 195: Line 202:
  
 
==== Configure audio ====
 
==== Configure audio ====
 +
 
{{Note|Everything should work by default, only change this if it doesn't work for you!}}
 
{{Note|Everything should work by default, only change this if it doesn't work for you!}}
 
To change the volume for mpd independent from other programs, uncomment or add this switch in mpd.conf:
 
To change the volume for mpd independent from other programs, uncomment or add this switch in mpd.conf:
Line 219: Line 227:
  
 
==== Changing user ====
 
==== Changing user ====
 +
 
{{Note|This is only required if you change the user!}}
 
{{Note|This is only required if you change the user!}}
 
Changing the group that MPD runs as may result in errors like "output: Failed to open "My ALSA Device"" "[alsa]: Failed to open ALSA device "default": No such file or directory" "player_thread: problems opening audio device while playing "Song Name.mp3""
 
Changing the group that MPD runs as may result in errors like "output: Failed to open "My ALSA Device"" "[alsa]: Failed to open ALSA device "default": No such file or directory" "player_thread: problems opening audio device while playing "Song Name.mp3""
  
This is because by default MPD runs as member of '''audio''' group and the sound devices under {{Ic|/dev/snd/}} are owned by this group, so add user {{Ic|mpd}} to group {{Ic|audio}}.
+
This is because by default MPD runs as member of '''audio''' group and the sound devices under {{Ic|/dev/snd/}} are owned by this group, so add user {{Ic|mpd}} to group {{Ic|audio}}:
 
  # gpasswd -a mpd audio
 
  # gpasswd -a mpd audio
  
 
==== Timeline of MPD startup ====
 
==== Timeline of MPD startup ====
 +
 
To depict when MPD drops its superuser privileges and assumes those of the user set in the configuration, the timeline of a normal MPD startup is listed here:
 
To depict when MPD drops its superuser privileges and assumes those of the user set in the configuration, the timeline of a normal MPD startup is listed here:
  
Line 237: Line 247:
  
 
=== Multi-mpd setup ===
 
=== Multi-mpd setup ===
 +
 
'''Useful if running an icecast server.'''
 
'''Useful if running an icecast server.'''
  
Line 242: Line 253:
  
 
== Clients ==
 
== Clients ==
A separate client is needed to control mpd. Popular options are:
+
 
 +
A separate client is needed to control mpd. See a long list of clients at the [http://mpd.wikia.com/wiki/Clients mpd wiki]. Popular options are:
  
 
=== Console ===
 
=== Console ===
 +
 
*{{App|mpc|Simple KISS client. All basic functionality available|http://mpd.wikia.com/wiki/Client:Mpc|{{Pkg|mpc}}}}
 
*{{App|mpc|Simple KISS client. All basic functionality available|http://mpd.wikia.com/wiki/Client:Mpc|{{Pkg|mpc}}}}
*{{App|ncmpc|A NCurses client for mpd|http://mpd.wikia.com/wiki/Client:Ncmpc|{{Pkg|ncmpc}}}}
+
*{{App|ncmpc|Ncurses client for mpd|http://mpd.wikia.com/wiki/Client:Ncmpc|{{Pkg|ncmpc}}}}
*{{App|[[ncmpcpp]]|An almost exact clone of ncmpc with some new features written in C++ (tag editor, search engine)|http://unkart.ovh.org/ncmpcpp/|{{Pkg|ncmpcpp}}}}
+
*{{App|[[ncmpcpp]]|Almost exact clone of ncmpc with some new features written in C++ (tag editor, search engine)|http://unkart.ovh.org/ncmpcpp/|{{Pkg|ncmpcpp}}}}
 
*{{App|pms|Highly configurable and accessible ncurses client|http://pms.sourceforge.net/|{{AUR|pmus}}}}
 
*{{App|pms|Highly configurable and accessible ncurses client|http://pms.sourceforge.net/|{{AUR|pmus}}}}
*{{App|vimpc|ncurses based MPD client with vi-like key bindings|http://sourceforge.net/projects/vimpc/|{{AUR|vimpc}}}}
+
*{{App|vimpc|Ncurses based MPD client with vi-like key bindings|http://sourceforge.net/projects/vimpc/|{{AUR|vimpc}}}}
  
 
=== Graphical ===
 
=== Graphical ===
*{{App|Ario|A very feature-rich GTK2 GUI client for mpd, inspired by Rhythmbox|http://ario-player.sourceforge.net/|{{Pkg|ario}}}}
+
 
*{{App|QmpdClient|A GUI client written with Qt 4.x|http://bitcheese.net/wiki/QMPDClient|{{Pkg|qmpdclient}}}}
+
*{{App|Ario|Very feature-rich GTK2 GUI client for mpd, inspired by Rhythmbox|http://ario-player.sourceforge.net/|{{Pkg|ario}}}}
*{{App|Sonata|An elegant Python GTK+ client|http://sonata.berlios.de/|{{Pkg|sonata}}}}
+
*{{App|QmpdClient|GUI client written with Qt 4.x|http://bitcheese.net/wiki/QMPDClient|{{Pkg|qmpdclient}}}}
*{{App|gmpc|GNOME Client|http://gmpc.wikia.com/wiki/Gnome_Music_Player_Client|{{Pkg|gmpc}}}}
+
*{{App|Sonata|Elegant Python GTK+ client|http://sonata.berlios.de/|{{Pkg|sonata}}}}
 +
*{{App|gmpc|GTK2 frontend for Music Player Daemon. It is designed to be lightweight and easy to use, while providing full access to all of MPD's features. Users are presented with several different methods to browse through their music. It can be extended by plugins, of which many are available.|http://gmpc.wikia.com/wiki/Gnome_Music_Player_Client|{{Pkg|gmpc}}}}
 
*{{App|Dmpc|Dmenu-based MPC client with a playlist manager and state-saving on playlist changes|http://wintervenom.mine.nu/|{{AUR|dmpc}}}}
 
*{{App|Dmpc|Dmenu-based MPC client with a playlist manager and state-saving on playlist changes|http://wintervenom.mine.nu/|{{AUR|dmpc}}}}
 
*{{App|Cantata|High-feature, Qt4/KDE4 client for MPD with very configurable interface|https://code.google.com/p/cantata/|{{AUR|cantata-qt}}}}
 
*{{App|Cantata|High-feature, Qt4/KDE4 client for MPD with very configurable interface|https://code.google.com/p/cantata/|{{AUR|cantata-qt}}}}
 +
 
=== Web ===
 
=== Web ===
*{{App|Patchfork|web client for MPD written in PHP and Ajax|http://mpd.wikia.com/wiki/Client:Pitchfork|{{AUR|patchfork-git}}}}.
 
  
See a long list of clients at the [http://mpd.wikia.com/wiki/Clients mpd wiki].
+
*{{App|Patchfork|Web client for MPD written in PHP and Ajax|http://mpd.wikia.com/wiki/Client:Pitchfork|{{AUR|patchfork-git}}}}.
 +
 
 +
== See also ==
  
== External links ==
 
* [http://mpd.wikia.com/wiki/Clients Sorted List of MPD Clients]
 
 
* [http://www.musicpd.org/forum/ MPD forum]
 
* [http://www.musicpd.org/forum/ MPD forum]

Revision as of 23:50, 2 July 2013

Summary help replacing me
Installation, configuration and basic troubleshooting of MPD.
Related Articles
MPD/Tips and Tricks
MPD/Troubleshooting
Other sources
Wikipedia article

MPD (music player daemon) is an audio player that has a server-client architecture. It plays audio files, organizes playlists and maintains a music database all while using very few resources. In order to interface with it, a separate client is needed.

Installation

The latest stable version of mpd is available in the official repositories.

Should users wish to run an experimental version, the AUR offers several from which to choose. For example, mpd-gitAUR.

Setup

MPD is able to run locally (per user settings), globally (settings apply to all users), and in multiple instances. The way of setting up mpd depends on the way it is intended to be used: a local configuration may prove more useful on a desktop system, for example.

For a proper MPD operation these are the necessary files and directories:

  • mpd.db - The music database
  • pid - The file where mpd stores its process ID
  • mpd.log - mpd logs here
  • mpdstate - mpd's current state is noted here
  • playlists - the folder where playlists are saved into

In order for MPD to be able to play back audio, ALSA, PulseAudio or OSS needs to be setup and working.

Local configuration (per user)

MPD can be configured per user (rather than the typical method of configuring MPD globally). Running MPD as a normal user has the benefits of:

  • A single directory ~/.mpd (or any other directory under /home/$USER/) that will contain all the MPD configuration files.
  • Easier to avoid unforeseen read/write permission errors.

To setup: create a directory for the required files and the playlists; copy the example configuration locally; create all of the requisite files:

$ mkdir -p ~/.mpd/playlists
$ cp /usr/share/doc/mpd/mpdconf.example ~/.mpd/mpd.conf
$ touch ~/.mpd/{database,log,state,pid}

Edit ~/.mpd/mpd.conf and specify the requisite files:

~/.mpd/mpd.conf
music_directory    "~/music"          # Can keep commented if XDG music dir.
playlist_directory "~/.mpd/playlists"
db_file            "~/.mpd/database"
log_file           "~/.mpd/log"
pid_file           "~/.mpd/pid"
state_file         "~/.mpd/state"
sticker_file       "~/.mpd/sticker.sql"

MPD can now be started by typing mpd on the command line (mpd first searches for ~/.mpd.conf, then ~/.mpd/mpd.conf, and then for /etc/mpd.conf [there is no support for XDG-config directory ~/.config/mpd/mpd.conf]). To specify the location of the configuration file :

mpd ~/.config/mpd/mpd.conf

To start MPD on login add to ~/.profile (or another Autostart file):

# MPD daemon start (if no other user instance exists)
[ ! -s ~/.mpd/pid ] && mpd

To start with the X.org server add to either xprofile or xinitrc. Some DEs ignore these files (GNOME does) and a desktop file must be placed in ~/.config/autostart/mpd.desktop:

[Desktop Entry]
Encoding=UTF-8
Type=Application
Name=Music Player Daemon
Comment=Server for playing audio files
Exec=mpd
StartupNotify=false
Terminal=false
Hidden=false
X-GNOME-Autostart-enabled=false

Autostart with systemd

Note: As of 2013-03-20 this functionality is still in development (forum thread). However, there is a workaround though it is peculiar as it requires a running X.org server to work.

Expected setup

  • Start user-session service (e.g. sudo systemctl enable user-session@USERNAME).
  • Add local service file ~/.config/systemd/user/mpd.service (see below).
  • Start local systemd /usr/lib/systemd/systemd --user &; enable service file systemctl --user enable mpd; start it systemctl --user start mpd.
  • Add /usr/lib/systemd/systemd --user & to ~/.profile or another autostart file.
  • Reboot and MPD start.
[Unit]
Description=Music Player Daemon

[Service]
ExecStart=/usr/bin/mpd %h/.config/mpd/mpd.conf --no-daemon
ExecStop= /usr/bin/mpd %h/.config/mpd/mpd.conf --kill

[Install]
WantedBy=default.target

Current setup (this hasn't worked for everybody)

As recommended above, it is best to use MPD as a service per user. In this case, we will use ~/.mpd/mpd.conf and not start mpd.service as a daemon for the whole system and all users. We will NOT use the /usr/lib/systemd/system/mpd.service which is intended to start the mpd.service as root and for all users.

Note: It is recommended to follow the instructions in the Systemd/User page fully, and to have your whole session managed by /usr/lib/systemd/systemd --user.

If you already enabled it, just disable it first.

If you used to start mpd inside your ~/.xinitrc, comment or delete the line

mpd ~/.mpdconf

Then, edit a new file ~/.config/systemd/user/mpd.service

~/.config/systemd/user/mpd.service
[Unit]
Description = Music Player Daemon

[Service]
ExecStart = /usr/bin/mpd --no-daemon
Restart = always

[Install]
WantedBy = default.target

Then, add this line to .xinitrc before any exec <session-command>

~/.xinitrc
#run systemd as user instance
/usr/lib/systemd/systemd --user &

Log out, log in your xsession. Let's first check mpd is not running. If yes, just kill it. If not, continue to the next step.

$ ps -ef | grep mpd

Now, enable and start mpd.service as per user

$ systemctl --user enable mpd
$ systemctl --user start mpd

Check the mpd status and see if mpd.service is correctly enabled and started

$ systemctl --user status mpd

Scripted configuration

Rasi has written a script that will create the proper directory structure, configuration files and prompt for the location of the user's Music directory; it can be downloaded here.

Global configuration

Warning: Users of PulseAudio with a local mpd have to implement a workaround in order to run mpd as its own user!

The default Arch install keeps the setup in /var/lib/mpd and uses mpd as default user.

Edit /etc/mpd.conf to reflect as such:

/etc/mpd.conf
music_directory       "/path/to/music/dir"
playlist_directory    "/var/lib/mpd/playlists"
db_file               "/var/lib/mpd/mpd.db"
log_file              "syslog"
pid_file              "/run/mpd/mpd.pid"
state_file            "/var/lib/mpd/mpdstate"
user                  "mpd"

We just configured MPD to run as the mpd user, but /var/lib/mpd is owned by root by default, we need to change this so mpd can write here:

# chown -R mpd /var/lib/mpd

Music directory

MPD needs to have +x permissions on all parent directories to the music collection (ie. if it's located outside of /var/lib/mpd). Thus users will most likely need to remount the music directory under a directory that mpd has access to -- this only applies if running as the 'mpd' user.

# mkdir /var/lib/mpd/music
# echo "/path/to/music/dir /var/lib/mpd/music none bind" >> /etc/fstab
# mount -a

Also see this forum thread.

An additional solution would be to just create a symbolic link into /var/lib/mpd/music.

# mkdir /var/lib/mpd/music
# ln -s /path/to/music/dir /var/lib/mpd/music/

If the music collection is contained under multiple directories, create symbolic links under the main music directory in /var/lib/mpd. Remember to set permissions accordingly on the directories being linked.

Start MPD

MPD can be controlled with the mpd daemon. The first startup can take some time as MPD will scan your music directory.

Test everything by starting a client application (ncmpc is a light and easy to use client), and play some music!

Configure audio

Note: Everything should work by default, only change this if it doesn't work for you!

To change the volume for mpd independent from other programs, uncomment or add this switch in mpd.conf:

/etc/mpd.conf
mixer_type			"software"

Users of ALSA will want to have the following device definition, which allows software volume control in the MPD client to control the volume separately from other applications.

/etc/mpd.conf
audio_output {
        type            "alsa"
        name            "My Sound Card"
        mixer_type      "software"      # optional
}

Users of PulseAudio will need to make the following modification:

/etc/mpd.conf
audio_output {
        type            "pulse"
        name            "pulse audio"
}

Changing user

Note: This is only required if you change the user!

Changing the group that MPD runs as may result in errors like "output: Failed to open "My ALSA Device"" "[alsa]: Failed to open ALSA device "default": No such file or directory" "player_thread: problems opening audio device while playing "Song Name.mp3""

This is because by default MPD runs as member of audio group and the sound devices under /dev/snd/ are owned by this group, so add user mpd to group audio:

# gpasswd -a mpd audio

Timeline of MPD startup

To depict when MPD drops its superuser privileges and assumes those of the user set in the configuration, the timeline of a normal MPD startup is listed here:

  1. Since MPD is started as root by systemd, it first reads the /etc/mpd.conf file.
  2. MPD reads the user variable in the /etc/mpd.conf file, and changes from root to this user.
  3. MPD then reads the contents of the /etc/mpd.conf file and configures itself accordingly.

Notice that MPD changes the running user from root to the one named in the /etc/mpd.conf file. This way, uses of ~ in the configuration file point correctly to the home user's directory, and not root's directory. It may be worthwhile to change all uses of ~ to /home/username to avoid any confusion over this aspect of MPD's behavior.

Multi-mpd setup

Useful if running an icecast server.

For a second MPD (e.g., with icecast output to share music over the network) using the same music and playlist as the one above, simply copy the above configuration file and make a new file (e.g., /home/username/.mpd/config-icecast), and only change the log_file, error_file, pid_file, and state_file parameters (e.g., mpd-icecast.log, mpd-icecast.error, and so on); using the same directory paths for the music and playlist directories would ensure that this second mpd would use the same music collection as the first one e.g., creating and editing a playlist under the first daemon would affect the second daemon as well. Users do not have to create the same playlists all over again for the second daemon. Call this second daemon the same way from ~/.xinitrc above. (Just be sure to have a different port number, so as to not conflict with the first mpd daemon).

Clients

A separate client is needed to control mpd. See a long list of clients at the mpd wiki. Popular options are:

Console

  • mpc — Simple KISS client. All basic functionality available
http://mpd.wikia.com/wiki/Client:Mpc || mpc
  • ncmpc — Ncurses client for mpd
http://mpd.wikia.com/wiki/Client:Ncmpc || ncmpc
  • ncmpcpp — Almost exact clone of ncmpc with some new features written in C++ (tag editor, search engine)
http://unkart.ovh.org/ncmpcpp/ || ncmpcpp
  • pms — Highly configurable and accessible ncurses client
http://pms.sourceforge.net/ || pmusAUR
  • vimpc — Ncurses based MPD client with vi-like key bindings
http://sourceforge.net/projects/vimpc/ || vimpcAUR

Graphical

  • Ario — Very feature-rich GTK2 GUI client for mpd, inspired by Rhythmbox
http://ario-player.sourceforge.net/ || ario
  • QmpdClient — GUI client written with Qt 4.x
http://bitcheese.net/wiki/QMPDClient || qmpdclient
  • Sonata — Elegant Python GTK+ client
http://sonata.berlios.de/ || sonata
  • gmpc — GTK2 frontend for Music Player Daemon. It is designed to be lightweight and easy to use, while providing full access to all of MPD's features. Users are presented with several different methods to browse through their music. It can be extended by plugins, of which many are available.
http://gmpc.wikia.com/wiki/Gnome_Music_Player_Client || gmpc
  • Dmpc — Dmenu-based MPC client with a playlist manager and state-saving on playlist changes
http://wintervenom.mine.nu/ || dmpcAUR
  • Cantata — High-feature, Qt4/KDE4 client for MPD with very configurable interface
https://code.google.com/p/cantata/ || cantata-qtAUR

Web

  • Patchfork — Web client for MPD written in PHP and Ajax
http://mpd.wikia.com/wiki/Client:Pitchfork || patchfork-gitAUR.

See also