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.
The following topics are covered below:
- .NET API to Manage MP3 tags
- Read MP3 ID3 Tags – ID3v1 & ID3v2
- Get MP3 Lyrics Tags
- Retrieve MP3 APEv2 Tags
.NET API for MP3 Tags Editor
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#.
- Load the MP3 file using Metadata class.
- 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.
Similarly, you can extract the ID3v2 tags. The following steps show how to retrieve the MP3 ID3v2 tags using C#.
- Load the MP3 file using Metadata class.
- Get the root package.
- 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.
Read MP3 Lyrics Tags in C#
The following steps guide to read the MP3 Lyrics tags using C#.
- 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, etc.
The following C# code snippet retrieves MP3 lyrics tags and some of its properties from the MP3 file.
Read MP3 APEv2 Tags in C#
The following steps show how we can extract the MP3 APEv2 tags using C#.
- Load the MP3 file using Metadata class.
- 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.
Get a Free API License
You can get a free temporary license to use the API without the evaluation limitations.
Conclusion
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.