Playing Music

From SingletonMillerWiki
Revision as of 12:41, 17 June 2012 by Martin (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Sound via Command Line

mpd is a music playing daemon [], this means its a server side service that runs on your RPi in the background. mpd builds and maintains a database of all your music so you can access it with a client for anywhere on our network.

Once properly configured mpd can be controlled via the command line utilities using a client tool such as mpc [1] or a console client like ncmpcpp. Graphical clients also exist.

sudo apt-get install mpd mpc ncmpcpp

This command will install the tools we need and automatically resolve a stack of dependencies. On my system it took about 10m to install everything.

Configuring mpd

By default the mpd install creates a conf file for you owned by user 'mpd' in group 'audio'.

sudo ls -all /etc/mpd.conf
-rw-r----- 1 mpd audio 12240 Jun  2 22:48 /etc/mpd.conf

Check that your user is in the 'audio' group using

cat /etc/group | grep audio

On my system this gave, which didn't have my user


If necessary add yourself to the group using;

sudo usermod -G audio <username>

With the correct permissions the audio group can read the conf file, therefore its still necessary to use root to modify it.

Modify the mpd config to point to your music folder

sudo nano /etc/mpd.conf

find the line that begins music_directory "~/music" and alter the location in "".

For example

music_directory         "/home/jack/music"

mpd runs as a service so to initialise using the new config use

sudo service mpd restart

Update the Database

mpd should be running and the best way to update the database is to use the client mpc,

mpc update
Updating DB (#1) ...
volume: 86%   repeat: on    random: on    single: off   consume: off

this may take a minute or two depending on how much music is parsed.

Loading a playlist to mpd

Navigating the database and selecting track for a playlist needs a client like ncmpcpp. Lauunch the utility using


Press '1' to get the command menu. Basically, press 'space' to add a file or folder to the playlist.

I've not found a way of saving a playlist.

When you quit ncmpcpp, mpd will continue playing.

Stop Playback

sudo mpd --kill


  1. mpd seems to reload the current playlist and start playing it automatically on RPi restart.
  2. sudo privs are needed to kill playback. This is because of permissions.
mpd --kill
config: problems opening file /etc/mpd.conf for reading: Permission denied


  1. Enable Sound