I started this because I was writing a media player in C# and I couldn't find any good libraries that could handle ID3v2. So I wrote one. It can handle:
ID3v1 (and 1.1)
This reads all v1 and v1.1 tags. The only difference between these two is the last byte of the v1 comment field has been hijacked for track number in v1.1. It also has write ID3v1 code but hasn't been really tested. Use at your own risk.
ID3v2 (2.2, 2.3, 2.4)
Reads all header info and creates a hash indexed by key and an array of frames. Parses some of the more common frames for Title, Artist, etc... All frames are available w/ contents held in a byte array for user parsing.
MPEG Header Info
Finds and reads mpeg header information.
References, Acknowledgements and Thanks
- the specs from www.id3.org
- Many Thanx to James Heinrich of SiliSoftware. I used his code as an example in a few places and he was very helpful to me on the mailing list
- Ralf for his coding ponters.
- I got my MPEG Header info from this great site.
The way I ended up writing this was in a couple classes. Yes it could be more elegant but I haven't been doing any real programming in a long time. Maybe I will massage it into some nicer form in the future. Anyway, here are the classes:
mp3info.csis the wrapper class. It contains the objects for the MPEG headers, id3v1 and v2 and some song length calculation code
MPEG.cscontains the code to find and read the MPEG headers.
ID3v1.cscontains the code to read and (possibly) write the id3v1 tags.
ID3v2.cscontains the code to read id3v2.2 - 2.4 tags. Some of the tags it parses into Title, Artist, Etc... the rest are stored in an array (in order read for later writing), and a hash (keyed by frame name)
BitReader.csWith all the flags and what not I had to deal w/ I ended up writing a class to convert a byte into an array of chars or bools representing the bits. this should be useful outside of this project.
id3v2Frame.csA subclass of id3v2 frames. contains the size, flags, name, and contents of a frame.
To Do (incomplete List):
- MPEG: length in seconds may be off b/c I don't take into account the presence of id3v1
- MPEG: no VBR Calc
- ALL: no error handling
- ALL: this could be done w/ inheritance if I wanted to get fancy
- v1: haven't tested update
- v2: must write update code
- v2: must write parsing code
- write better webpage
- write some usage docs
- set up versioning