Metadata variants are attached with documents of different file formats. MP3 files commonly contain ID3 metadata tags. This article discusses how to read different MP3 tags in Java. One by one, we will see how to extract ID3 (IDEv1, ID3v2), Lyrics, and APEv2 metadata tags from the mp3 files using Java Metadata API.

The following topics are covered below:

Java API for MP3 Metadata Tags

GroupDocs.Metadata is equipped with APIs to automate metadata management of various file formats within applications. It’s Java API allows you to read, update, add, clean, and remove the metadata for many file formats within the Java application. We will use it to work with MP3 metadata tags.

Download and Configure

Get the metadata library from the downloads section. For your Maven-based Java application, just add the following pom.xml configuration. After this, you can try the examples of this article as well the many more example available on GitHub. For the details, you may visit the API Reference.

<repository>
	<id>GroupDocsJavaAPI</id>
	<name>GroupDocs Java API</name>
	<url>http://repository.groupdocs.com/repo/</url>
</repository>
<dependency>
        <groupId>com.groupdocs</groupId>
        <artifactId>groupdocs-metadata</artifactId>
        <version>22.2</version> 
</dependency>

Read MP3 ID3 Tags in Java - ID3v1 & ID3v2

The following steps show how to read the MP3 ID3v1 tags using Java.

  • Load the MP3 file using Metadata class.
  • Retrieve the MP3RootPackage using the getRootPackageGeneric() method.
  • From the root package, retrieve each of the ID3v1 properties.

The following Java source code reads some of the MP3 ID3v1 tags of the MP3 file.

You can extract the ID3v2 tags in a similar way. The following steps show how to retrieve the MP3 ID3v2 tags in Java.

  • Load the MP3 file using Metadata class.
  • Get the root package.
  • From the root, you can easily retrieve all the ID3v2 tags like Artist, Composers, Publisher, Title etc.
  • Details for attached pictures can be retrieved from the properties of Attached Picture Frames.

The following Java source code example reads some of the MP3 ID3v2 tags and attached pictures details of the MP3 file.

Read MP3 Lyrics Tags in Java

The following steps guide how to read the MP3 Lyrics tags in Java.

  • Load the MP3 file using Metadata class.
  • Retrieve the root package.
  • From the root, you can get lyrics tags and its properties like Lyrics, artist, track etc.

The following Java code snippet retrieves MP3 lyrics tags and some of the properties from the MP3 file.

Read MP3 APEv2 Tags in Java

The following steps showing how we can extract the MP3 APEv2 tags within Java application.

  • Load the MP3 file using Metadata class.
  • Retrive the root package using getRootPackageGeneric() method.
  • From the root, you can retrieve the APEv2 tags like Album, Genre, Copyrights, Language, etc.

The following Java code examples read some of the properties of MP3 APE tags of an MP3 file.

Get a Free API License

You can get a free temporary license to use the API without the evaluation limitations.

Conclusion

To sum up, we learned how to extract metadata tags from the MP3 files in Java. One by one, we read ID3v1, ID3v2, Lyrics, and APE tags and their properties from the MP3 files. Think about building your own MP3 online tag editor & metadata viewer just like Online Metadata App.

Learn more about the API from the documentation and contact us for queries via the forum.

See Also