Geertjan's Blog

  • August 3, 2006

MP3 Manager on NetBeans Platform

Geertjan Wielenga
Product Manager
Yesterday was the first week day since I started this blog, as far as I'm aware (outside of vacations), that I didn't blog! And that's because I spent the time I normally spend blogging on extending the MP3 Manager a bit. Now multiple files can be opened (thanks to late night e-mails to and from Pierre Matthijs) and the properties display correctly (thanks to local super engineer Andrei Badea). So, from a user interface perspective, the result is currently as follows:

I'm going to restart this application from scratch because it doesn't have much of a domain model. I started developing it mostly to work with the TreeTableView, as discussed in the day before yesterday's blog entry. But, now that it's clear that it's pretty easy to get quite far with the de.ueberdosis.mp3info library, I'm going to start again and prepare the ground properly. So, consider this a prototype!

One of the strengths of the NetBeans Platform is definitely the ease with which you can integrate third party libraries (such as, in this case, the de.ueberdosis.mp3info library). There's a template that bundles such a library in two or three clicks into your application. And then you can use the library just as you would use any library provided by the JDK. Code completion and all the rest is seamlessly available for third party libraries. And, in answer to Opsi's question (in the comments at the end of the most recent blog entry) about how to use this particular library from Java, here is a basic example:

        RandomAccessFile ra = null;
try {
ra = new RandomAccessFile(getCurrentFile(), "rw");
myTag = myReader.readExtendedTag(ra);
} catch (FileNotFoundException ex) {
} catch (IOException ex) {
String Artist = myTag.getArtist();
String Album = myTag.getAlbum();
String Title = myTag.getTitle();

In fact, that's the only part of the API that I've used thus far. Look at the second line within the try block. It uses a method called readExtendedTag(RandomAccessFile). When you use that method, you can retrieve all of the following information (or a subset thereof):

The rest of the application, apart from the snippet above, is nothing more than standard JDK classes and a handful of the NetBeans APIs. Note that, for the above snippet, you'd need the following import statements:

import de.ueberdosis.mp3info.ID3Reader;
import de.ueberdosis.mp3info.ID3Tag;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;

It is a pretty cool library and, once I've designed a domain model, I hope to leverage a lot more of its functionality.

In other news. Check out this great technical writing blog, by Microsoft's Harry Miller, which includes a podcast for each blog entry, with interviews and interesting food for thought on subjects such as "Author's Voice" and "Thinking Visually". Check it out and enjoy.

Join the discussion

Comments ( 5 )
  • opsi Thursday, August 3, 2006
    Hi Geertjan,
    thanks!, now I understand why I didn't find the java bindings. Using the packages you gave I found that the lib you are using should be mp3info (but there was a link in the post to id3lib which is a C++ lib), isn't it?
  • Geertjan Thursday, August 3, 2006
    Aaargh. My mistake. Sorry! I've just gone back and fixed the links in the last two blog entries, so that they now point to the correct location and use the full package name (because there seem to be several libraries called "id3lib" or "mp3"-something. At least, the package name is unique. Thanks again for pointing this out and sorry for the confusion.
  • Lukas Monday, August 7, 2006
    3rd mp3 player

  • Geertjan Monday, August 7, 2006
    Not a player. A manager.
  • Lukas Tuesday, August 8, 2006
    ok, sorry. I missed it :(
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.