Since gwillem over at the NMT forums posted his compiled version of Music Player Daemon for Popcorn Hour, I was searching to use the Popcorn Hour like an Apple Airport Express. The AirTunes function of the Airport Express allows the device to receive audio coming from iTunes, and feed it to your home stereo.
How great the MPD might be, I couldn’t find any client that acts like iTunes does. Theremin was the only Mac client I could find, but unfortunately it crashed on me too often. Minion is a Firefox add-on which worked very well, but it’s UI is ugly in my opinion.
That’s why I still wanted to use iTunes as the “client” for MPD.
What you will need
- A networked media tank, like PopCorn Hour of course.
- A Mac with iTunes.
- NiceCast, an application that broadcasts any audio on your Mac.
- Music Player Daemon installed on your NMT. This can be installed using the Community Software Installer.
- Dropbear SSH Server installed on your NMT.
The scripts to make it all work
I created two AppleScripts which I put in /Library/iTunes/Scripts. You can also put them in the equivalent folder in your homedir. I just prefer to put them in the system-wide library folder, because the script is then available to all users on the Mac.
The first script is called Start stream to NMT. It’s doing the following steps:
- It mutes the system volume of the iMac. I don’t want to hear iTunes playing through the internal speaker of course !
- It starts NiceCast, which is a very nice audio streamer from Rogue Amoebe. I have setup NiceCast to start streaming audio coming from iTunes when the application starts up.
- Finally it starts the mpd daemon on the Popcorn Hour, and tells it to play the stream coming from NiceCast.
Here’s the script:
set volume 0
tell application “Nicecast”
launch
end telldelay 2
do shell script “ssh root@popcorn ‘export MPD_HOST=localhost; export MPD_PORT=6600; /share/Apps/mpd/daemon.sh start; mpc stop; mpc clear; mpc add http://192.168.123.1:8000/listen; mpc play’”
The second script, as you might have guessed, is called Stop stream to NMT. It’s doing these things:
- It tells mpd to stop playing the stream.
- Shuts down the daemon. I don’t want the daemon to be running all the time as it disrupts video playback.
- It shuts down NiceCast, as there’s no need to stream the audio anymore.
- Finally it unmutes the system sound of the iMac.
Here’s the code:
do shell script “ssh root@popcorn ‘mpc stop; /share/Apps/mpd/daemon.sh stop”’
tell application “Nicecast”
quit
end tellset volume 2
If you have any questions or remarks about this, don’t hesitate to contact me !