O'Reilly logo

Microsoft® Visual Basic® .NET Programmer's Cookbook by Matthew MacDonald

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Read Header Information from MP3 Files

Problem

You need to read information about the song, artist, and album from an MP3 file.

Solution

Read the ID3v2 tag from the end of the MP3 file.

Discussion

Most MP3 files store information in a 128-byte ID3v2 tag at the end of the file. This tag starts with the word TAG and contains information about the artist, album, and song title in ASCII encoding. You can convert this data from bytes into a string using the Encoding object returned by the System.Text.Encoding.ASCII property.

The MP3TagData class shown here provides access to MP3 data, and it provides a ReadFromFile method that retrieves the information from a valid MP3 file.

Public Class MP3TagData Private _Artist As String Private _SongTitle As String Private ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required