Sometime around the beginning of July I rewrote our internal jukebox in Erlang. It’s taken me four months to get a round tuit, but new stock has just arrived: here’s the code for our AJAX jukebox
web-application, as a tarball. (There’s also a mercurial repository:
hg clone http://hg.opensource.lshift.net/erlang-jukebox/.)
Click on the image for a screenshot.
* You point the jukebox at one or more root URLs, which it then spiders, collecting URLs for MP3 and OGG files, which it puts into a simple flat-file database. Just expose, say, your iTunes folder via Apache, point the Jukebox at it, and you’re away.
* It relies on mpg123 and ogg123′s support for playing HTTP-streamed MP3 and OGG files, respectively, rather than retrieving or playing the media itself.
* The server side of the application communicates with the user interface solely via JSON-RPC.
* Erlang made a great platform for the server side of the application. Its support for clean, simple concurrency let me design the program in a very natural way.
As part of the development of the program, I built a few stand-alone modules that others might be interested in reusing:
and its associated Erlang href=”http://hg.opensource.lshift.net/erlang-jukebox/file/default/src/execdaemon.erl”>controller
module is a filthy hack I threw together to get better than the built-in support for POSIX process control and signalling from Erlang.
is a tiny, simple layer atop href=”http://hg.opensource.lshift.net/erlang-jukebox/file/default/priv/server_root/htdocs/json.js”>json.js
[Update: fixed an issue with json.js, tweaked the use of screen real-estate, and now seems to work with Safari, IE6, and Opera. I've changed the tarball link above to point to the new version.]
[Update: fixed a couple of links that had broken over time as the darcs repository evolved.]
[Update: moved from darcs to mercurial, and altered the links to reflect the change.]