Click here to Skip to main content
15,120,937 members
Articles / Programming Languages / Visual Basic
Posted 6 Mar 2006


54 bookmarked

Reading ID3 tags from a WMA file (MP3 as well)

Rate me:
Please Sign up or sign in to vote.
4.00/5 (22 votes)
6 Mar 20061 min read
A pair of classes to read the ID3 tags from either a WMA or MP3 file.


I wanted to get to the ID3 taqs (artist, album, title, genre, ...) in a WMA file, and found out that it's not quite as straightforward as it is getting the ID3V1.1 tags from an MP3 file. So I created a set of classes, one to get the ID3V1.1 tags from an MP3 file (easy), and another to get the same information out of a WMA file.


You can find the ASF specification here: Advanced Systems Format (ASF) Specification. It is the internal file format of a WMA file.

Using the code

The classes are fairly straightforward to use. You simply create an instance of either WMAID3Tag or ID3V1Tag, specifying the filename of the music file, and then you can access the key information directly:

// Allocate a WMAID3Tag and access the fields
    w = New WMAID3Tag(tbFilename.Text)
Catch ex As Exception
    MsgBox(tbFilename.Text & " is not a valid wma" & _ 
           " file or has invalid tag information")
End Try

tbTitle.Text = w.title
tbArtist.Text = w.artist
tbAlbum.Text = w.album
tbGenre.Text = w.genre
tbYear.Text = w.year.ToString
tbTrack.Text = w.track.ToString
tbDescription.Text = w.description

Points of Interest

One interesting side note is that the .NET classes that read/write Unicode strings (like BinaryReader/Writer or StreamReader/Writer) use an interesting convention for the length field at the start of the string. It appears that strings less than 255 characters use a single byte for the length, but others use two bytes. It's not clear (to me) exactly how this works, but since in the WMA files the length field is always two bytes, you can't use the .NET routines.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Comments and Discussions

QuestionRead other WMA Attributes Pin
Member 1028717321-Jul-14 12:57
MemberMember 1028717321-Jul-14 12:57 
QuestionNice, very nice but... Pin
Metafunken10-Nov-13 3:51
MemberMetafunken10-Nov-13 3:51 
GeneralMy vote of 5 Pin
Be Yourself20-Oct-10 18:14
MemberBe Yourself20-Oct-10 18:14 
GeneralReally Appreciate! Pin
dongwon_kang14-Mar-10 7:01
Memberdongwon_kang14-Mar-10 7:01 
GeneralThanks a million Pin
grismun14-Jan-09 15:00
Membergrismun14-Jan-09 15:00 
QuestionHow can we access the other values in a WMA file? Pin
yarborg21-Oct-08 12:00
Memberyarborg21-Oct-08 12:00 
Generalother WMA information Pin
jingyeu10-Apr-08 22:03
Memberjingyeu10-Apr-08 22:03 
QuestionVB5 Pin
hobbitdome23-Nov-07 4:58
Memberhobbitdome23-Nov-07 4:58 
GeneralThis is good Pin
Hamed J.I21-Oct-07 6:49
MemberHamed J.I21-Oct-07 6:49 
GeneralC# Version Pin
Murpheux Melony24-Feb-07 7:01
MemberMurpheux Melony24-Feb-07 7:01 
GeneralRe: C# Version Pin
DalePres21-Mar-07 13:35
MemberDalePres21-Mar-07 13:35 
GeneralRe: C# Version Pin
vinyasa6-Apr-07 19:28
Membervinyasa6-Apr-07 19:28 
GeneralRe: C# Version Pin
Shiku-5784124-Sep-11 19:49
professionalShiku-5784124-Sep-11 19:49 
Questionsetting the tag values... Pin
Michael Elly13-Aug-06 11:04
MemberMichael Elly13-Aug-06 11:04 
AnswerRe: setting the tag values... Pin
Andy Lang17-Dec-06 15:44
MemberAndy Lang17-Dec-06 15:44 
AnswerRe: setting the tag values... Pin
CalhounIND22-Aug-07 9:25
MemberCalhounIND22-Aug-07 9:25 
GeneralRe: setting the tag values... Pin
Relentless3-Oct-07 9:25
MemberRelentless3-Oct-07 9:25 
GeneralRe: setting the tag values... Pin
Member 173839027-Aug-08 21:29
MemberMember 173839027-Aug-08 21:29 
AnswerRe: setting the tag values... Pin
grundt2-Apr-10 20:47
Membergrundt2-Apr-10 20:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.