Click here to Skip to main content
Licence 
First Posted 6 Mar 2006
Views 92,551
Bookmarked 51 times

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

By | 6 Mar 2006 | Article
A pair of classes to read the ID3 tags from either a WMA or MP3 file.

Introduction

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.

Background

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
//
Try
    w = New WMAID3Tag(tbFilename.Text)
Catch ex As Exception
    MsgBox(tbFilename.Text & " is not a valid wma" & _ 
           " file or has invalid tag information")
    Return
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.

License

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

danhi



United States United States

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralMy vote of 5 PinmemberBe Yourself17:14 20 Oct '10  
GeneralReally Appreciate! Pinmemberdongwon_kang6:01 14 Mar '10  
GeneralThanks a million Pinmembergrismun14:00 14 Jan '09  
QuestionHow can we access the other values in a WMA file? Pinmemberyarborg11:00 21 Oct '08  
Generalother WMA information Pinmemberjingyeu21:03 10 Apr '08  
QuestionVB5 Pinmemberhobbitdome3:58 23 Nov '07  
GeneralThis is good PinmemberHamed_ji5:49 21 Oct '07  
GeneralC# Version PinmemberDapo Onawole6:01 24 Feb '07  
GeneralRe: C# Version PinmemberDalePres12:35 21 Mar '07  
GeneralRe: C# Version Pinmembervinyasa18:28 6 Apr '07  
GeneralRe: C# Version PinmemberMember 287158018:49 24 Sep '11  
Questionsetting the tag values... PinmemberMichael Elly10:04 13 Aug '06  
AnswerRe: setting the tag values... PinmemberAndyLang14:44 17 Dec '06  
AnswerRe: setting the tag values... PinmemberCalhounIND8:25 22 Aug '07  
GeneralRe: setting the tag values... PinmemberRelentless8:25 3 Oct '07  
GeneralRe: setting the tag values... PinmemberMember 173839020:29 27 Aug '08  
Did you ever find how to set wma tag?
AnswerRe: setting the tag values... Pinmembergrundt19:47 2 Apr '10  

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

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

Permalink | Advertise | Privacy | Mobile
Web03 | 2.5.120604.1 | Last Updated 6 Mar 2006
Article Copyright 2006 by danhi
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid