MPD

From Gentoo Wiki
Revision as of 22:31, 29 March 2012 by Needle (Talk | contribs)

Jump to: navigation, search
External resources

Music Player Daemon (MPD) is a flexible, powerful, server-side application for playing music. Through plugins and libraries it can play a variety of sound files while being controlled by its network protocol. For more information, read about what mpd is and is not.

Contents

Installation

Following minimal USE flags set is needed to be able to play most known audio file formats, and to listen to audio streams. For more features review the USE flags.

→ Information about USE flags
USE flag Default Recommended Description
alsa No Yes Adds support for media-libs/alsa-lib (Advanced Linux Sound Architecture)
curl No Yes Support for web stream listening
flac No Yes Adds support for FLAC: Free Lossless Audio Codec
id3tag No Yes Support for ID3 tags
mad No Yes Adds support for mad (high-quality mp3 decoder library and cli frontend)
ogg No Yes Adds support for the Ogg container format (commonly used by Vorbis, Theora and flac)
sqlite No Yes Adds support for sqlite - embedded sql database
unicode No Yes Adds support for Unicode
vorbis No Yes Adds support for the OggVorbis audio codec
wavpack No Yes Add support for wavpack audio compression tools
root # emerge --ask --verbose media-sound/mpd

Make sure MPD is configured before first run. If ready, MPD can be added to default runlevel and started:

root # rc-update add mpd default
root # /etc/init.d/mpd start

Configuration

After finished installation MPD should be working with the gentoo shipped default configuration. Below a example of a simple configuration:

File/etc/mpd.confBasic MPD configuration

 music_directory      "/var/lib/mpd/music"
 playlist_directory   "/var/lib/mpd/playlists"
 db_file              "/var/lib/mpd/database"
 log_file             "/var/lib/mpd/log"
 state_file           "/var/lib/mpd/state"
 
 user                 "mpd"
 
 bind_to_address      "localhost"
 bind_to_address      "/var/lib/mpd/socket"
 
 input {
        plugin "curl"
 }

At this point MPD should be able to run as a system daemon with its own user called mpd, which is the default setting of MPD.

Additional configuration options are described in sections below.

PulseAudio

Build MPD with pulseaudio USE flag and add dedicated audio_output:

File/etc/mpd.confPulseAudio output definition

 audio_output {
        type            "pulse"
        name            "Pulse Output"
        mixer_control   "Master"
 }
Important
System-wide instance for the PulseAudio server is strongly discouraged by upstream.

It may be a good practice to run both PulseAudio and MPD under X11 user instead.

Built-in HTTP streaming server

Build MPD with network USE flag and add dedicated audio_output to /etc/mpd.conf

File/etc/mpd.confHTTP stream output definition

 audio_output {    
 	type		"httpd"    
 	name		"HTTP Stream"    
 	encoder		"vorbis"                # optional, vorbis(OGG) or lame(MP3)
 	port		"8000"      
 	bitrate		"192"			# do not define if quality is defined      
 	format		"44100:16:1"    
 }
 
bind_to_address "0.0.0.0"

Replace localhost with 0.0.0.0 or a specific interface IP. Bind to address 0.0.0.0 means here: stream on all local found IP interfaces. You could change it to a specific interface IP address like f.e. 192.168.1.2 then the streaming server is bound to that interface IP only.

Note
Some players require to specify the file format in the URL to be able to connect to the stream. Example: http://192.168.1.2:8000/mpd.ogg

Running as a specific user

Sometimes it may be handy to run MPD as a specific user.

Start with copying /etc/mpd.conf to ~/.mpdconf. There are some changes that you will have to change in order to run MPD as a user, most importantly user and group, also make sure the various path settings are correct:

File~/.mpdconfuser definition

  user    "my-user"
  group   "my-group"

Make sure your user has read access to the directory you specify in music_directory.

Note
If your cron program supports @reboot you can create a cronjob that has /usr/bin/mpd start at boot in place of the init script.

Clients

Command-line

Extras

Troubleshooting

For general troubleshooting refer to the excellent MPD troubleshooting section

See also

Personal tools
Namespaces

Variants
Actions
Gentoo Websites logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Navigation
Toolbox
Categories