How to Make the Music Player Daemon (MPD) Autoplay on a Raspberry Pi

{}
November 13th, 2018

Music Player Daemon (MPD) is a terrific open source music player and maintains a good organized library of your music in an efficient database. MPD is a server so you need a client. That can be your laptop, to your phone, your browser, your whatever, or you can run a client on your Rpi locally (mpc). Or all together.

It does run fine on the cheapest raspberry pi, so your ready to go for 5 euro. The Pi only has a high quality HDMI output, for older Hifi systems with analogue connections  you need something like the HifiBerry.

MPD uses much less CPU then running Kodi, 4% instead of 40% on the original Raspberry Pi.

Furthermore you can put your music on an external USB stick or  NAS with Linux NFS or the slightly inferior Microsoft Windows Samba shares.

If you haven’t installed MPC yet, do that first:

sudo apt install mpc

Normally MPD will resume play after shutting down, but to make MPD auto-play always simply add this to your systemd.service  file:

ExecStartPost=/usr/bin/mpc play

How to do that? Just edit the file:

sudo vi  /etc/systemd/system/multi-user.target.wants/mpd.service

And add it under the line starting with `ExecStart`

...
[Service]
EnvironmentFile=/etc/default/mpd
ExecStart=/usr/bin/mpd --no-daemon $MPDCONF
ExecStartPost=/usr/bin/mpc play
....

Save it, stop MPD, and reboot your pi. And the music will play 😉

Tags:

Leave a Reply