CMP – Central Music Playback System using MPD

Geek, Lighting Tech, Maker

CMP – Central Music Playback System using MPD

Using MPD/MPC for Radio Paradise morning wakeups

Install mpd and mpc

sudo apt-get install mpd mpc

By default MPD looks for music files in the folder /var/lib/mpd/music playlist files are stored in the folde/var/lib/mpd/playlists

Add radio paradise playlist

Add the following lines to the file  /var/lib/mpd/playlists/rp.m3u
If the file does not exist then create it.

http://stream-tx3.radioparadise.com:80/aac-128
http://stream-tx4.radioparadise.com:80/aac-128
http://stream-eu1.radioparadise.com:80/aac-128

Start script

~/bin/rp

#!/usr/bin
mpc clear
mpc load rp
mpc play 

Then make the file executable


chmod +x ~/bin/rp

This file clears the current MPD play queue, loads the radio paradise playlist into the play queue and starts the stream

Stop script

~/bin/off

#!/usr/bin
mpc clear


Make the file executable

chmod +x ~/bin/off

with nothing in the play queue MPD automatically stops playing


Configuration

Change the following lines in your /etc/mpd.conf file

bind_to_address "localhost"
to
bind_to_address "any"

and check that

auto_update "yes"

is correct and uncommented

Alarms:

For a wakeup alarm at 7 AM every weekday


Run crontab -e and add the line

0 7 * * 1-5 ~/bin/rp

For a wakeup alarm at 6 AM every weekday

Run crontab -e and add the line
0 6 * * 1-5 ~/bin/rp



To run in the system wide crontab
make an /opt/bin folder
copy, or symlink ~/bin/rp to /opt/bin
and
add the following line to your /etc/crontab file
0 6 * * 1-5 mpd /opt/bin/rp

NOTE: For system crontab usage you MUST add a user to run the script as, I recommend the mpd user.


For a simple GUI MPD Client



sudo apt-get install gmpc

Edit your ~/.bashrc file and add the following line at the end of the file

PATH=$PATH:~/bin

Then restart MPD to allow the new configuration to be set


sudo service mpd restart

Starting / Stopping

Now to start radio paradise use the command rp and to stop radio paradise / your alarm use the command off


Example Use Case:

If flint wanted to play an audiobook like neuromancer I would recommend unpacking the tar.gz file of the audiobook in the /var/lib/mpd/music folder and using the following /var/lib/mpd/playlists/neuromancer.m3u}}} file

William_Gibson_-_Neuromancer/01-12_WGN_William_Gibson_-_Neuromancer.mp3
William_Gibson_-_Neuromancer/02-12_WGN_William_Gibson_-_Neuromancer.mp3
William_Gibson_-_Neuromancer/03-12_WGN_William_Gibson_-_Neuromancer.mp3
William_Gibson_-_Neuromancer/04-12_WGN_William_Gibson_-_Neuromancer.mp3
William_Gibson_-_Neuromancer/05-12_WGN_William_Gibson_-_Neuromancer.mp3
William_Gibson_-_Neuromancer/06-12_WGN_William_Gibson_-_Neuromancer.mp3
William_Gibson_-_Neuromancer/07-12_WGN_William_Gibson_-_Neuromancer.mp3
William_Gibson_-_Neuromancer/08-12_WGN_William_Gibson_-_Neuromancer.mp3
William_Gibson_-_Neuromancer/09-12_WGN_William_Gibson_-_Neuromancer.mp3
William_Gibson_-_Neuromancer/10-12_WGN_William_Gibson_-_Neuromancer.mp3
William_Gibson_-_Neuromancer/11-12_WGN_William_Gibson_-_Neuromancer.mp3
William_Gibson_-_Neuromancer/12-12_WGN_William_Gibson_-_Neuromancer.mp3


To load and play the book I would use the following commands

mpd clear mpd load neuromancer mpd play 1 

Where 1 is the track number

To pause the playback use


mpc pause

Travel Uses

For travelling in the car it may be nice for the audio to auto pause to do this I recommend setting your laptop up as a hotspot and using

MPDroid

After installing connect to your laptop’s ad-hoc wifi network and enter in the IP information of the laptop into MPDroid on the phone, in the MPDroid settings set the options “Pause when in a call” and ” resume playback when call ends”

To remotely control the MPD from another linux box install mpc
sudo apt-get install mpc

and then run
mpc -h <hostname or ip address of MPD computer> command
example

mpc -h 10.0.1.34 pause
or
mpc -h music play 

Note “music” is the hostname of 10.0.1.34 on the flint network }}}

Quick Tips

Make an alias for mpc on remote computers such as the following

alias mpc='mpc -h 10.0.1.34'

Another useful alias is
alias mpt='mpc toggle'

This toggles between pause/play

For more information on MPC


man mpc

Comments: 1

  1. rashid noman says:

    Excellent article, congratulations & thanks for sharing! 🙂

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.