ID3 Tags, JAudiotagger, JLayer

Audio players such as iTunes provide you with the ability to import into your library all audio files in a given directory. Typically, you specify the directory, and the program provides you with a list of all MP3 files found. Instead of listing the names of the files, which might be something like '21 Let It Be.mp3', you will see the Artist, Title, and Album for the given song. This information is embedded into the MP3 file itself in the ID3 tags.

ID3 Tags

MP3 (Moving Picture Experts Group-1 Audio Layer 3) refers to the format used to store audio data. You can open and read an mp3 file, but most of the contents will appear as gibberish if viewed as text. As MP3 started to become a standard for storing audio data, it became clear that being able to include some textual information in an mp3 file, for example the artist of a song, would be useful. ID3 tags were proposed for this purpose. The first version of ID3 stored metadata about the file in the last few bytes. The recent version of ID3 (ID3v2) stores the metadata at the beginning of the file.

The ID3 standard describes how the metadata will appear in the file. It specifies the tags that can be present, for example:

TPE1

The 'Lead artist/Lead performer/Soloist/Performing group' is

used for the main artist

http://www.id3.org/id3v2.4.0-frames

jAudiotagger

You could build your own library to extract the ID3 tags from MP3 files. Fortunately, there are several libraries available that will do this for you. jAudiotagger is one example. The jAudiotagger documentation provides a clear example of how to use the library to extract Artist, Album, Title, and other information:

http://www.jthink.net/jaudiotagger/examples_read.jsp

JLayer

The JLayer library provides support for playing, decoding, and converting mp3 files. The javazoom.jl.player.Player class makes it very easy to playback an mp3 file as follows:

player = new Player(is);

player.play();

If a file is playing and you wish to stop playback, you can invoke the close method of the Player class.