By Kevin Yank

Playing MP3s with Java

By Kevin Yank

In my off hours, I’m building a spanky Web interface for JJukebox, an open source, multi-user MP3 jukebox server. We take our music pretty seriously here at SitePoint HQ, and it’s time our rusty, old, Perl-based MP3 jukebox software got a revamp.

If there is one weak point in the JJukebox server implementation, it’s the audio playback–specifically, the handling of MP3 files. Despite all its cutting-edge vitality, Java’s support for multimedia is in a sad state indeed.

Going by the book, the Java Media Framework API (JMF) is a one stop shop for capture and playback of all kinds of streaming media. Though MP3 support was removed after JMF 2.1.1a due to the same patent issues that are affecting other open source MP3 software, the Windows version of JMF 2.1.1c reinstated MP3 playback by using the MP3 support in Windows, and since November JMF 2.1.1e now has a MP3 plug-in for all supported platforms (Windows, Linux, Solaris, and a cross-platform version).


Unfortunately, JMF is reportedly incompatible (or at least buggy) with Java 5, and the only sign of life for the API is a comment left by the manager of the Java Client Group’s Swing team on April 12th to the effect that they have taken over responsibility for JMF and will have something to announce Real Soon Now. Personally, I couldn’t even get the JMF 2.1.1e installer to run on my Windows system.

Some recent words of wisdom on what should be done with JMF may be found in JMF, wherefor art thou? on Mason Glaves’s blog, and Java Media without Mediocrity on Chris Adamson’s blog. The executive summary: stop the “Weekend at Bernie’s”-esque sham, let JMF die and make room for more qualified options.

Anyway, for the above reasons, JJukebox abandoned JMF for MP3 playback quite some time ago (the CVS comment upon removal of the JMFPlayer class: “JMF is dead. Long live JMF.”), and adopted JavaZoom‘s JavaLayer instead. If MP3 playback with Java is something you need to do, JavaLayer is the best thing out there right now. For most practical applications, you’ll actually want to use JavaZoom’s BasicPlayer API, which talks to Java’s built-in Java Sound API, which can use JavaZoom’s MP3SPI (a wrapper for JavaLayer) for MP3 playback and JavaZoom’s VorbisSPI (a wrapper for JOrbis) for Ogg Vorbis (an MP3 alternative) playback.

Confused yet? Me too, but with the latest versions of all the necessary libraries installed, it actually works pretty well. That isn’t to say there isn’t still room for improvement. According to one JJukebox author:

I’m part of the JJukeBox project ( We’re eager to find a decent ogg/mp3 player, that isn’t based on JMF or JavaLayer (JlGui). Both are completely rubbish, and any patches we submit to JavaZoom (JavaLayer/JlGui) are ignored, and we’ve had to heavily rewrite parts of JlGui to make it remotely usable. I was quite amazed at how poor parts of the project were, in terms of the (non existent) events system, for example.

If you know of a project that will do ogg/mp3s reliably (broken and knackered mp3s/oggs, with a proper events system and the ability to multi-thread) then please let us know!

  • James Austin

    I don’t know if it’s relevant, but I wrote a little client/server mp3/wma jukebox for use in my office. It’s windows only, doesn’t yet do ogg files (tho it shouldn’t be hard to add) and it only plays from the PC the server app runs on (no fancy streaming). It’s called TCPlayer and can be found at

  • I don’t understand but why do you guys use a web-based Jukebox for music at SitePoint? Why not just install Shoutcast on one of the machines in the LAN & then stream multiple feeds from it. The client machines can have Winamp or any other music player & listen to any of the available streams!! I call them LAN Radio Stations!! ;)

  • We use a single office sound system to play the music for the entire office. The jukebox’s function is to allow anyone to request tracks from the library, control the volume, etc. With the new jukebox software, it will be aware of who is in the office and avoid playing tracks that they don’t like (according to individual ratings).

  • soil

    Hi everyone,
    because of my project work, i have to use ogg vorbis format music in it. can anyone help me about this? i will be happy if u contact me.

  • Ken Larson

    Your description of the state of JMF is very accurate.

    I wanted to point out that a handful of developers are working on FMJ, an open-source implementation of JMF.

    While we are still heavy in development, we do have the ability (among other things) to playback WAV, AU, AIFF, and MP3/OGG with the JavaZoom SPIs, all using the JMF architecture.

    Anyone interested should visit

Get the latest in Java, once a week, for free.