My Lost Streaming MP3 Article
by Chris Adamson
Related link: http://jicyshout.sourceforge.net/oreilly-article/
By "http-based MP3 streams", I'm talking about Shoutcast and Live 365, mostly, both of which use a similar protocol for streaming web radio. Stations using these systems aren't big commercial stations, which tend to use DRM'ed Real or Windows Media to play the same 50 crappy songs you never need to hear again (especially "Hotel California" and "Gold Dust Woman"). Instead, they tend to be tiny niche-casters broadcasting real jazz, anime and j-pop, an all-Zappa playlist, etc. In other words, with the exception of KFOG's "10@10", Shoutcast and Live 365 stations are the only webcasters I can stand to listen to.
So I started experimenting with the JMF to figure out why it could play MP3 files, locally or off a server, but not streams. JMF has
rtp/rtsp streaming support, but that's not what we're talking about here. The http streams are easier for a client, because you never have to worry about dropped data - you're guaranteed to get everything. In this standard, the heavy lifing is on the server side.
What I found was that the class that plays MP3s is
com.sun.media.content.unknown.Handler, so I set out to get him to be able to play the http stream. What I eventually figured out is that JMF is very dependent on the protocol and filename extension of a URL to decide what Player, if any, can handle the content, and it couldn't figure out what to do with something like
http://188.8.131.52:8000 (Fanelia.com RPG Radio) or
http://www.live365.com/play/45939 (Anime Hardcore 1).
Oh and during this time, my son was born with a totally scary heart condition that required surgery four days after birth, so I put this work down for the three weeks we were at the hospital. Shortly after that, I applied to be a presenter at the O'Reilly Mac OS X Conference and amazingly (since my MP3 player wasn't done yet), they accepted my talk on java media.
Long story short - I got it to work in a somewhat nice JMF kind of way, and while I was reading the stream myself, I threw in parsers for popular metadata formats like ID3 and Shoutcast.
The conference wanted speakers to write a companion article for one of the O'Reilly websites, so I whipped up a pair of articles using jicyshout as the sample code - the first was about the JMF side of how it works, the second was about the various metadata formats.
Then the stupid thing happened.
There was apparently some sort of licensing fiasco regarding MP3's, and Sun responded by making JMF unavailable for a few weeks, then posting a new 2.1.1b version that removed MP3 support.
Obviously, this had a fairly lethal effect on both jicyshout and my articles about it. Nobody who downloaded the code could play MP3's with it if they didn't already have a pre-2.1.1b JMF, making the code and the articles instantly worthless. I decided to hold the articles for a while to see if Sun ever put the MP3 support back - it was, after all, practically the only useful format suppored by JMF - but it never happened. Indeed, from the looks of the website and the lack of new content in the last seven months, JMF seems almost utterly abandoned.
So, now that it's been a year, I've posted the articles to the jicyshout website in hopes that they'll do someone some good. They're unedited and somewhat dated - ignore everything about icecast, which has dropped MP3 in favor of Ogg Vorbis in the past year. But on the other hand, the shoutcast in-stream metadata format is very poorly documented, and I have a decent write up of that (and code to parse it!), so the more we can disseminate that information, the better.
Web radio in java... what was I thinking? Does this project do anyone any good at all?
What about Ogg Vorbis?
I admit I'm rather light on the knowledge of all this, but why not use Ogg Vorbis in jicycast instead of MP3? Doesn't the JMF allow for the extension of its acceptable formats? Ogg Vorbis support in Java sounds like a pretty good OS project to me.
Re: What about Ogg Vorbis?
You're right, Vorbis and Java sound like a good match. In fact, it's the number six request for enhancement on the JDC bug parade.