Linux: Hold Music Server

Originally posted at techsays.com on February 25nd, 2007.

At work we have a rack mounted CD player that we’ve used for years to play music for people that get placed on hold.

In order to not burn up the thing, every morning we have to turn it on, wait for it to initialize, press play, wait for it to start playing, and then press repeat twice. Oh yeah, it’s mounted on the very bottom of a rack in the back of the data center. Every night we have to turn it off.

Since I just built a server for a client, I was in the mood to fix this small problem at work. I checked our existing servers to see if they had sound cards and not a single one does. We just replaced all of the client workstations at two of our remote locations and one of the systems we replaced, if you can believe it, was an OLD Optiplex GX100. I can’t believe the user of this workstation wasn’t complaining every single day about this thing. It’s OLD and SLOW! Perfect for an mp3 server.

After installing Debian on it I was off to find an mp3 daemon. I finally settled on MPD as the backend and ncmpc, and mpc as front ends.

When installing the software, I used the command (taking the defaults):

apt-get install mpd ncmpc mpc

I looked at a few of the web frontends but I couldn’t find any that I really liked. I didn’t look at Ampache, but I did try phpMp2 and couldn’t get it to create playlists without creating duplicates or just not working at all.

I don’t rip a lot of CDs so I just used Windows Media Player to rip the CDs into mp3 format. I don’t have any problems with the player as a video player or mp3 ripper, but I don’t care for it at all when put to the task of playing music. Winamp and Foobar both do a much better job of it.

After ripping the music, I SCP’d it to my home directory and moved it to /usr/share/mpd/music/.

I didn’t really spend the time to learn how to create playlists and such. Instead, I used a set of commands I found on some website:

mpc search artist elvis | mpc add -; mpc play

That works great, as long as you use id3 tags when ripping your music.

And finally, I wanted to make sure that music started playing automatically if the server was ever rebooted.

I wrote a small script and put it in /etc/init.d.

cat /etc/init.d/mpc.sh

#!/bin/bash
mpc clear
mpc search artist elvis | mpc add -
mpc play

I made sure to make the script executable with

chmod +x /etc/init.d/mpc.sh

And finally, with Debian, I made sure to create the symlinks in /etc/rc2.s:

upudate-rc.d mpc.sh defaults

Now I have a server that will play hold music for us automatically.

WordPress database error: [Table 'wp_comments' is marked as crashed and should be repaired]
SELECT * FROM wp_comments WHERE comment_post_ID = '322' AND comment_approved = '1' ORDER BY comment_date

Leave a Reply