There are different metadata standards that are used with MP3 files. Various types of data can be stored using different standards. In this article, we will discuss how to read different MP3 tags using C#. Specifically, we will learn to extract ID3v1, ID3v2, Lyrics, and APEv2 metadata tags from the mp3 files within the .NET application.
GroupDocs.Metadata provides .NET API to automate metadata management of various file formats within .NET applications. The API allows to read, update, add, clean, and remove the metadata for many file formats. We will use this API to deal with metadata tags of MP3 files.
You can download the DLLs or MSI installer from the downloads section or install the API in your .NET application via NuGet.
PM> Install-Package GroupDocs.Metadata
Read MP3 ID3 Tags using C# – ID3v1 & ID3v2
The following steps show how to read the MP3 ID3v1 tags using C#.
Retrieve the root package using the GetRootPackage() method.
From the root, you can retrieve each of the ID3v1.
The following C# source code reads some of the MP3 ID3v1 tags of the MP3 file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From the root, you can retrieve all the ID3v2 tags like Band, Artist, Composers, etc.
For the attached pictures and their details, use the AttachedPictures properties.
The following C# source code example reads some of the MP3 ID3v2 tags and attached pictures details of the MP3 file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From the root, you can get lyrics tags and its properties like Lyrics, artist, etc.
The following C# code snippet retrieves MP3 lyrics tags and some of its properties from the MP3 file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Retrive the root package using GetRootPackage() method.
From the root, you can retrieve all the APEv2 tags like Album, Genre, Copyrights, Language, etc.
The following C# code examples read some of the properties of MP3 APE tags of an MP3 file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
To conclude, we learned to extract metadata tags from the MP3 files using C#. We read ID3v1, ID3v2, Lyrics, and APE tags and their properties from the MP3 files. You can learn more about the API from the documentation and contact us for queries via the forum.