JLayer, Java MP3 decoder

For a hobby project, I wanted to play and analyze MP3 files from a Java program. It turns out that’s not as easy as you might think. Probably due to licensing issues MP3 playback is not included with the standard Java development kit. Luckily there are some great people at JZoom (formerly JavaZoom) have created an open source library to help out: JLayer (formerly JavaLayer).

The documentation is minimal, but who needs it when programming a Java MP3 player is as simple as:

new Player(new FileInputStream(args[0])).play();

The code itself is also very legible, which is nice if you plan to mess with it. And they have a few add-ons. The one you will want is the JavaSound standard library. Using MP3 SPI, JLayer integrates perfectly with JavaSound, so you don’t actually need to learn any new APIs if you already know JavaSound.

Image credit.