Perry’s ID3 Tag Library

ID3v2Perry’s ID3 Tag Library is a free open-source ID3v1 and ID3v2 tag parsing utility for MP3 files that has been tested to work with Visual Studio, VB.NET, ASP.NET, Visual Basic for Applications and VBScript.

Use the library as a reference in your own Visual Studio project to parse ID3 tag data embedded in MP3 files, or use the ActiveX control to give familiar Microsoft Office products such as Word and Excel the ability to parse ID3 tags. This library is useful for anyone looking to implement ID3 tag capabilities in their own custom solutions and applications.

You might be interested in Perry’s ID3 Tag Viewer which is a full implementation of the current ID3 Tag Library version.

Tag Writing is currently in the works as of May 2012!

The ID3TagLibrary is pretty simple to use:


Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  ' create an mp3 object from a file on the hard drive
  Dim mp3 As New ID3TagLibrary.MP3File("C:\song.mp3")
  ' put the mp3's title into a label control
  Label1.Text = mp3.Title
  ' put the mp3's artwork (if any!) into a picturebox control
  PictureBox1.Picture = mp3.Tag2.Artwork
End Sub

News

  • September 13, 2013 – Version 0.4 is now on Github! I recently started experimenting with MPEG header frame parsing which will make information available such as song duration, bitrate, sampling rate, etc.
  • September 9, 2013 – New version 0.4 is here! Jump to the Downloads.
  • May 30, 2012 – So writing ID3v2 tags is a more formidable opponent than I first realized, but that’s not to say I haven’t made tons of progress! Version 0.3 could read tags just fine, but the code I wrote to do that was fairly lightweight and it skipped over some of the deeper ID3v2 data and details such as text encoding and padding bytes. As it turns out, I now need to consider those details in order to write out the tags correctly so they are compatible. This means having a solid understanding of low level computer science concepts like bits, hex, binary and unicode, which I did not have a firm grasp on until last week! There are even more considerations here like having to split and rejoin the file when a frame’s value is modified to something larger than the frame’s original size, and preserving the text encoding used for modified text frames. I have some very promising code in the works that I’ve been writing tags successfully with, but I have a few bugs to iron out (written tags show some corrupt data Winamp) and some code to tidy up before releasing a new version.
  • May 23, 2012 – Tag writing works in development! I can now change a frame’s text value or picture (album art) and save it, but only if the frame doesn’t need to be enlarged. Enlargement will require splitting and rejoining the file, so I still need to develop that. Stay tuned for v0.4…
  • May 22, 2012 – due to the rising interest in this library and several feature requests, I’ve started implementing ID3 tag writing. I have a great prototype in the works for writing tags which I think even the most seasoned power users will enjoy. You can also expect many of the workarounds and bugs mentioned in the comments section here on this page before May 2012 to be ironed out in the next version release. As usual, I’ll also release a new version of the ID3 Tag Viewer which implements these changes.
  • July 20, 2011 – version 0.3 released.
  • April 19, 2011 – version 0.2 released.
  • March 28, 2011 – version 0.1 released.

Features

  • Parse ID3v1 and ID3v2 (ID3 2.2, ID3 2.3, ID3 2.4) tag data, including most/all frames outlined in the official ID3 spec.
  • Embedded picture frames (APIC) are converted to native System.Drawing.Image objects for ease of access.

System Requirements

  • Visual Studio, VBScript or VBA

Screenshots

Coming soon!

Downloads

Instructions

Visual Studio Usage Example

This example will show you how to use the ID3TagLibrary natively in an existing project.

  1. Extract the Visual Studio project from the SOURCE download to your computer.
  2. Open Visual Studio and create a new host project that will utilize the ID3TagLibrary. Choose the VB.NET Windows Forms Application project template. By default this will be named  WindowsApplication1.
  3. Add an existing project (File > Add > Existing Project). Browse to the ID3TagLibrary.vbproj file and open it. Since you now have two projects, Visual Studio creates a top level Solution file in the Solution Explorer, and the two projects appear beneath this.
  4. In the Solution Explorer, select the host project (WindowsApplication1) and add a reference to the ID3TagLibrary (Project > Add Reference).
  5. When the Add Reference dialog appears, click the Projects tab, select the ID3TagLibrary then click OK.
  6. Open the code window for Form1 in the host project (WindowsApplication1). In the Form_Load event, write the following code:
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Dim myMP3 As New ID3TagLibrary.MP3File(“C:\test.mp3”)
    MessageBox.Show(myMP3.Artist)
    End Sub
  7. Run the WindowsApplication1 project (F5 or Debug > Start Debugging). When the blank Form1 appears, it should show a MessageBox with the Artist name from the MP3’s ID3 tag.

VBScript Usage Example

This example will show you how to use the ID3TagLibrary through VBScript.

  1. Save the dynamic link library ID3TagLibrary.dll file to your computer.
  2. Register the ID3TagLibrary.dll file on your computer using REGASM:
    1. Open a command prompt (Start > All Programs > Accessories > Command Prompt) and navigate to the directory where you saved the ID3TagLibrary.dll file. For example, if you saved it to the desktop you would type:
      cd %userprofile%\desktop
    2. Then execute the following REGASM command:
      %windir%\microsoft.net\framework\v2.0.50727\regasm ID3TagLibrary.dll /codebase
  3. Create a new text file and rename it to VBScript.vbs.
  4. Open VBScript.vbs in NotePad and code a reference to the ID3TagLibrary’s ComParser interface and access some MP3 file info:
    Set myParser = CreateObject(“ID3TagLibrary.ComParser”)
    MsgBox myParser.ParseMP3(“C:\test.mp3”).Artist
  5. Save and close the VBScript file, then double click the file to execute it. It should show a MessageBox with the Artist name from the MP3’s ID3 tag.

Microsoft Access 2002 Usage Example

This example will show you how to use the ID3TagLibrary in a Microsoft Access file.

  1. Save the type library ID3TagLibrary.tlb file to the client computer.
  2. In Access, open the Visual Basic Editor (Tools > Macros > Visual Basic Editor). In the Visual Basic Editor, open the References dialog (Tools > References).
  3. Click Browse and locate the ID3TagLibrary.tlb file. Click Open; the ID3TagLibrary is added to the list of Available References, with a checkmark. Click OK to close the References dialog.
  4. In the Visual Basic Editor, insert a new module (Insert > Module).
  5. In the Module1 (Code) window, code a Sub for testing our COM interop and access some MP3 file info:
    Sub TestComInterop()
    Set myParser = New ID3TagLibrary.ComParser
    MsgBox myParser.ParseMP3(“C:\test.mp3”).Artist
    End Sub
  6. Place your cursor in the TestComInterop Sub and execute it (F5 or Run > Run Sub/Userform). It should show a MessageBox with the Artist name from the MP3’s ID3 tag.

Want to see a full list of properties and methods? Just open the Object Browser in Visual Studio and navigate the ID3Library:

Object Browser

More documentation coming soon…

Disclaimer

All of my software comes with the same disclaimer. I do test and use my own software programs, and while I’m pretty confident there are no dire consequences to using them, I can’t be held liable for any damage caused by the use of my software, whether due to bugs, unforseen functionality or any other reason. I always recommend that you test my software on a sample before attempting the real thing. This will give you an idea of how it works and what to expect. Thank you for your interest in my software!

Related

Tags: , ,

119 Comments

  1. Jason Knapp says:

    Hello, I have 2 questions about your ID3Library dll.
    1. I can add the reference to the dll in visual studio, and work with it, but when I try to register the dll on my system I get an error saying the dll was loaded but the entry-point dllregisterserver was not found….make sure that it is a valid dll or osx file.
    2. I am trying to use it to look up the ID3 tag of a song and rename the .mp3 accordingly from the tag, and I have been successful in that., but since the dll locks the file in process, I can’t rename the file. Do you have a way of removing the file from the process after I already read it’s tag info?

    Thanks!

    • Jason, I’ve posted a new version of the ID3 Tag Library (v0.2) and included some usage examples on this page. You may want to check those out.

  2. Hello,

    I found your library and I am very interested in using it. However, for the sake of my project I must know; what is the license for this library?

  3. Jason, I will look into these issues, it’s possibly a bug or something I have overlooked.

    • Thanks for all the work Perry. Even though I get the regsvr32 error, it seems that the dll still registers. I am able to add the reference to my project with no problems. I use this dll to loop through a folder of mp3’s to read the ID3 of a mp3 and create a copy of it and rename it accordingly. The only problem is that the dll will not release the last file to be deleted. Unless I call GC.Collect(), no files can be deleted, but once I make the call, like I said, all files will delete as planned, except for the last file. I get an error stating file is locked in the vshost32 process. I think a Dispose method is needed. I haven’t looked at your version 2 yet, so it may already be in there, but if not, do you have any ideas on how to unlock the last file I’m reading so I can delete it without having to close my app first. Thanks again!

    • Jason, I think the problem with registering the DLL has been sorted out; I recommend checking out the new Instructions section on this page.

      If you look further down in the comments you’ll see that Bob also had problems trying to register the DLL. Right off the bat, I found out that you cannot register the DLL using RegSvr32; you must use RegAsm for this, which is standard practice for registering DLL’s created with the .NET framework.

      Since RegAsm also requires that the DLL you are trying to register contains a “strong name”, I had to sign the DLL in Visual Studio, recompile it, and release version 0.2. I also included a TLB file with version 0.2 which can be used in Microsoft Access.

      The problem you describe with the DLL not releasing a file until you call GC.Collect is likely a bug in the code where it is not releasing a file handle that it created.

      In fact, it probably has to do with the ParseTag method in the ID3v2Tag.vb file. This method calls gTagReader = argFileInfo.OpenRead, but never follows up with a call to gTagReader.Close or gTagReader.Dispose. This same problem can also be seen in the New method of the ID3v1Tag.vb file; there is a call to Dim mReader As IO.FileStream = argFileInfo.OpenRead, but no follow up call to mReader.Close or mReader.Dispose.

      I will test this and get back to you.

  4. Victor, I was wondering that myself, but I think I have an answer for you. As I am not overly familiar with open source software licensing, I would say your best bet would be to adhere to the GPL license as this is the one I will probably adopt for this project. Basically, I don’t want to get screwed over by someone who tries to copyright the library I spent time developing. If/when I write a tutorial on how to develop this library, it would likely become public domain. What is the project that you’re working on?

  5. Thank you for your prompt reply, my project will be GPL’d so there should be problem. I really like your library, keep up the good work!

  6. I’m having the same problem as Jason when trying to register the id3library.dll.

    Just for your information. I’m on a Windows 7 computer.

    This looks like a good library and I’m anxious to put it to use. Thanks for your work on this.

  7. Jason & Bob, it looks like the .NET equivalent of RegSvr32 is called RegAsm.

    So, move the ID3Library.dll file under C:\Windows\System32, then run the following command from a DOS prompt to register it:

    “C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\regasm” ID3Library.dll /codebase

    I have noticed that this command complains about the assembly not having a strong name and not being in the GAC, but registers anyway. Though I don’t see the library available in Visual Studio, so we still have a problem somewhere. I might be able to correct this by signing the assembly with a key, or by registering the library with the GAC. I’ll get back to you guys when I have an overall solution.

    Another tip I found on the web that might help: If you don’t want to use RegAsm, you can create a setup & deployment project, add the primary output files and set the property Reg to Com = True.

  8. OK I think I have this figured out. First of all, I would like to ask…in what way are you trying to use the dll? It might not be necessary to register it, according to common advice I have seen so far. One could simply add a reference to the dll file in their project and be good to go. Now, if you wanted to use this dll through VBScript or something, you DO need to register the dll. I’ve also figured out how to do that.

    I created a test dll to see where I went wrong. From a development perspective, I had to do several things to be able to call the .NET dll from COM:

    1. Create a new “Class Library” project called ClassLibrary1.
    2. Add a module to the project called Module1.vb, and inside this Module add a Sub “MyTest” that simply calls MsgBox(“Hello World!”).
    3. Add a new item to the project, based on the COM Class item template (Add -> New Item -> COM Class). This will be called ComClass1.vb. The idea is that public methods within this class will be exposed to COM, so we can expose our real class methods by creating wrappers for them in ComClass1.vb.
    4. Add a new Public Sub “MyTestCaller” to ComClass1.vb, which simply calls Module1.MyTest, to expose our actual method.
    5. Create a strong name for the assembly. At first this was confusing because I tried using the SN.EXE utility (included with Visual Studio / .NET runtime) as recommended by several Microsoft articles. Then I discovered this could all be done through Visual Studio using the Signing tab of my Project’s properties.
    6. Recompile the assembly.
    7. Copy the assembly to another computer and register it using the REGASM.EXE utility, outlined here. The command was: “C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\regasm” ClassLibrary1.dll /codebase
    8. Create a VBScript file (test.vbs) which contains some code that will utilize the registered assembly. For example: first create an instance of the object using Set obj = CreateObject(“ClassLibrary1.ComClass1”) and then call obj.MyTestCaller, which should generate a messagebox that says “Hello World!” through VBScript!

    So, that still leaves us with broken COM interop for the ID3Library.dll. I will look into applying this concept to the ID3Library.dll and release a new version soon enough.

    Thanks for the feedback, as always!

  9. I appreciate your efforts in trying to resolve this. I am still not able to register the dll or use it in my code.

    What I want to do is use it in a Microsoft Access Database program. When I look for it in the list of references, I don’t see it. I am assuming that this is because it is not registered.

    The error that I am receiving when using regasm is “error RA0000 : Unable to locate input assembly ‘id3library.dll’ or on of its dependencies.”

    Thanks for your continued efforts.

    • Bob, i’ll test your scenario with Access and let you know what to do. Maybe you just need to register it in the Global Assembly Cache using GACUTIL, or add a reference to the .tlb file (type library) which I did not include with the current download. You won’t be able to register the id3library.dll from this website using REGASM because it is not signed/strongly named. I’ll upload a signed v0.2 ID3Library.dll, ID3Library.tlb, source code, and a few common implementation examples within the next few days.

    • Bob, after researching your problem using my copy of Access 2002 (XP), I’ve got it working on my end.

      First off, it appears you are not calling REGASM from the directory in which your DLL resides, hence the error. I assumed you would first navigate to where your DLL was located on your system before calling the REGASM command. I’ve also discovered that REGASM is sometimes located elsewhere under [%WINDIR%\Microsoft.NET\Framework\v2.0.50727]. Secondly, you won’t be able to add a reference to the DLL file through Access, you need to add a reference to the TLB file, which you may be able to find in the /Release folder of the source code download on this page, or you can create it yourself by recompiling the source code.

      Here’s how I was able to get this working based on my ClassLibrary1 test project scenario from earlier in our discussion:

      Open Visual Basic: (ALT+F11 or Tools -> Macro -> Visual Basic Editor). Then in Visual Basic open the References window: (Tools -> References). This is where we need to implement our reference.

      In the References dialog, I clicked Browse and selected the ClassLibrary1.dll, which threw an error “Can’t add a reference to the specified file.” Then I tried making a reference to the ClassLibrary1.tlb file (which is a type-library that also gets generated by Visual Studio and output to the /Release folder) and this appeared to work! I inserted a code Module (Module1.vb) and added a Sub called “TestMyReference”. Inside this Sub I wrote some code to verify that I could access the properties and methods of my ClassLibrary1.tlb: “Dim myReference as ClassLibrary1.ComClass1”, and below that we finally call “myReference.GetInfo” to execute our test messagebox.

      As I said earlier, I understand some people might have trouble implementing these changes as I have described them here, and I find it somewhat of an advanced topic myself, so the next version of ID3Library (v0.2) will definitely contain these COM-friendly implementations, as well as some proper documentation.

      I’ve enjoyed working through this new challenge with you.

    • Bob, I’ve posted a new version of the ID3 Tag Library (v0.2) and included some usage examples on this page. You may want to check those out.

  10. Thanks for continuing to try to make this work. Unfortunately, I am still having problems.

    First, just to let you know that in my prior attempt, I was calling the regasm from the directory where I had the dll and now the tlb.

    If I try to register the latest files with regasm, it gives me an “Unable to locate input assembly . . . or one of its dependencies” error.

    I went to Access and tried to add a reference there. It is kind of odd because if I go to the folder where they files are downloaded onto my computer, it see the files and was able to add a reference to the tlb without error.

    I also had tired add a reference from the windows\system32 folder where I had placed these files, but I don’t see them when I bring up the “Add Reference” window. They are definitely there (I can see them in Windows Explorer), but I don’t see them even though the “Add Reference” windows is should *.olb, *.tlb and *.dll files.

    Anyway, I ran your sample and set an error “ActiveX component can’t create object” error on the “Set myParser = New ID3TagLibrary.ComParser” line when trying to run the program.

    What do you think?

    • Bob, sounds like we need to get REGASM working first. Your error probably means it can’t find the DLL at the path specified. You might need to use full paths. Try this instead…

      1. I assume you downloaded and saved the v0.2 DLL file to C:\Program Files\ID3TagLibrary.dll.
      2. Execute this command from a command prompt:
        "%windir%\microsoft.net\framework\v2.0.50727\regasm" "C:\Program Files\ID3TagLibrary.dll" /codebase

      Let me know what happens.

  11. When I run the command I get an error telling me that I must have administrative credentials to perform this. I am logged in as an administrator.

    • Bob, if you are on Windows Vista or Windows 7 then you probably need to “Run As Administrator” on the Command Prompt shortcut. There are three ways to do this, check out this link. Please report back with your findings!

  12. I was able to register the .dll and run the sample code!

    I’m still a bit confused about the registration. When I put the dll in windows/system32 and try to register, it fails. When I try to register it from a folder in dowloads, it fails. But when I register it from c:\program files, it works. I thought maybe it was a fluke so I tried several times from each location and it would only register it from c:
    program files.

    Anyway, i can now play with it and see how it works. Thanks for your help.

  13. Perry, Thanks so very much for putting this library together!

    I’m able to obtain data from all of the values except “Title” and “Year”. I verified my mp3 does have a title as well as a year and that its other data is being pulled successfully.

    Has anyone else reported this issue?

    Thanks again for creating this library because it saved me a huge amount of time on a personal project of mine.

    Dan

    • Dan, glad to be of assistance. What id3 tag version does your mp3 use? Have you checked your mp3 in other programs such as Winamp or Mp3Tag? If you want, email the mp3 to me and I can debug the library against it. I’m curious to see what my ID3 Tag Viewer can see in your mp3 file…

  14. I have tried numerous approaches to read the title and artist from a MP3 ID3 tag and place the information into a table in Microsoft Access. I can not seem to get it right. Could you please post a working ACCESS example file? Thank you for you work on this project.

  15. Hey Perry,

    what a great piece of software you have created here. It works flawlessly for me besides ONE minor thing. I discovered 3 files, that cannot be read by your library. They result in a System.OutOfMemoryException if a loaded mp3 file calls Function GetID3EncodedSizeV4(ByVal argBytes() As Byte) As String. argBytes() values are all four above 100, which results in some ridiculously high number, which my memory cannot handle. This only happens to three files in my library, if I remove them, the library loads without problems and all tags are read. If you would like, I can send one or all three mp3s via email so you can take a look at them. They are each around 4mb.

    Any help resolving this would be very much appreciated 🙂

    Thanks!

    • So, after tinkering around with your dll for 4 days now and not coming up with a solution, I just discovered the issue after i posted my comment. I narrowed the error down to reading a mp3 file containing lyrics. I had one file containing lyrics which could not be read and a direct copy without stored lyrics (removed in iTunes). The copy without lyrics could be read. Anyhow, maybe this gives you an idea on how to extend your library. I, for sure, would very much appreciate it. Thanks!

    • OMG. lol. So one more update (I hope that this is ok?): One file is version 2.2 the other 2.3 and the one with lyrics is 2.4. I cannot find the reason for your dll not loading it (2.2 and 2.3). All my other music works fine. Let me know if I can send them to you for further investigation 🙂

    • Mario, first of all thank you very much for your feedback, I know others will benefit from your findings. Your problem is quite simple actually…I didn’t add lyrics support yet, and the only reason I can think of for leaving out lyrics support is uh…my MP3’s don’t have lyrics so I didn’t notice the problem. Oops!

      Go ahead and send over a few of the MP3 files you have. I’ll debug them so I can at least see what’s going on.

    • Sent you an email. Check the spam folder too (it’s an @usa.com email)

    • Our problem has something to do with synchsafe integers and the unsynchronization scheme used by ID3v2. Basically, a frame’s size can be stored as a synchsafe integer (28 bits) or a regular integer (32 bits). This usually depends on how the ID3 tags are written by various tag writing software; unsynchronization is for avoiding “false sync signals” and is typically not used, but newer tag writing software seem to be using it.

      I cannot determine whether to parse the tag/frame as a regular integer or synchsafe integer. According to the ID3 spec, we should be able to determine whether a tag/frame is unsynchronized or not by checking the header/frame flags. However, through my testing I have never seen this unsynchronization bit set to 1, so I cannot determine when to parse it as a regular integer or synchsafe integer.

      Furthermore, I’m not the only one who seems to be having this problem. I tried opening your “TQ – Westside” MP3 in Winamp and found that it could not parse a single portion of the ID3 tag nor would it play the song! Through debugging my ID3TagLibrary agains your MP3, the problem appears when it encounters the lyrics frame (USLT) in your MP3. USLT means an unsynchronized lyrics frame, so I may just need to include a check for that specific frame and treat this frame’s size as a synchsafe integer.

      If anyone has a solution please do share! I’ll be working on it in the meantime…

    • Wow Perry, now this is what i call insight! So glad you took some time to look into these issues for all of us. I am currently very occupied by my new job, but once it slows down i will be back on track with developing and testing your library. it really is great to see somebody care about their creation.

      thanks again and i will report back with some testing experiences soon. 🙂

    • Sheesh…the ID3 spec can be really confusing when it comes to tag/frame sizes. Dare I say that I think I’ve got it figured out now?

      I’ve rewritten the methods for parsing the tag/frame sizes and things seem to be working much better. I’m now able to open all of the mp3 files you had trouble with, as well as any mp3 I throw at it so far…

      To make this work I recreated the size parsing methods: GetEncodedSizeV2, GetEncodedSizeV3, and GetEncodedSizeV4. V2 can be used for all ID3v2.2.0 tags. V3 can be used for tags/frames that have not been synchronized (these are called “unsynchronized”). V4 can be used for tags/frames that have been synchronized (“synchsafe”). As such, even though your TQ – Westside mp3 is an ID3v2.4.0 tag, it has an Unsynchronized Lyrics Text frame (USLT), which means we must use V3 to parse this frame, therefore we include a specific check for the USLT frame and handle this one specially.

      One more thing I’ve implemented, when the ID3TagLibrary encounters an invalid frame size, it simply aborts safely and stops parsing at that point. This allows the ID3TagLibrary to be able to parse one of your mp3’s that had some extra “MP3ext” text injected into the ID3 tag by specific tag writing software called MP3ext. I would also think this will help with other mp3’s containing malformed tags as well.

      Finally, I’ve uploaded a new version of my ID3 Tag Viewer which includes these fixes. I’ll upload the ID3TagLibrary dll and source code to this page very soon. I’d still like to do a bit more testing.

  16. Hi Perry:
    I really like your library. I tried to make a few changes, and that doesn’t seem possible. For example, the Artwork function has a parameter it never uses, I tried to fix it, and the system screamed at me about dll registration, etc. Is there anyway to use this code within my program without going thru the dll approach?
    Sincerely,
    Ed

    • Hi Edwin, I’d like to help you get to the bottom of this. If I understand your problem, you modified the source code, recompiled the dll, then tried to register it and it threw an error? It sounds like there might be a problem with compiling where the signature key file is not correctly being applied to the dll. I had some issues with this myself, so if this seems to be your problem I’ll check my dev notes and share my solution.

      Not everyone likes using the dll, so I might include a command line utility in one of the future releases.

      But I’d also like to add…

      I believe the Artwork function and specifically the unused parameter has been changed in version 0.3; have you tried it yet? I also released version 0.6 of my ID3 Tag Viewer which uses version 0.3 of this library. The ID3 Tag Viewer handles Artwork better with the ability to view multiple Artwork frames (PIC or APIC) per file.

      You asked if there was another way than using the dll. You can add the entire ID3 Tag Library project to your existing Visual Studio Solution as a Project Reference. With a Project Reference, you’ll have full integration of the library, plus you can modify and recompile the library directly within your Solution.

      Hope that helps. Let me know what you find out.

  17. Hi Perry:

    I downloaded this zip: Perry’s ID3 Tag Library v0.3 SOURCE.zip

    And I have added it to my project, as you directed. It works great, but it compiles to a dll, instead of putting the code into my EXE. When I tried to modifiy the code, I just wanted to delete the extra parameter to Artwork, it compiled okay, but then when I ran my EXE, Vista complained about the new dll. I didn’t understand the error message… and I didn’t write it down. I corrected this issue by going back to the original download, deleting the stuff I had worked on, and replacing with the exact files as downloaded. They recompiled and ran without a problem. It is a mystery to me.

    I have already written my own tag library which includes ogg support (not in my released code yet), and I was trying out your code because I was going to add support for the artwork, which you already have written (save me some work). I think what I will try to do is incorporate your code as a Class in my project and use it that way — that is how I did mine. It senses the mp3/ogg on-the-fly by checking the 3 chars at the start of the file, for “OGG” upper or lowercase.

    At this point, I call my library to get all the text frames, then if the user sets a flag to display album art, I call your library to get the picture. So far it is working pretty good in my tests, but I do have an extra dll to distribute, and that gets to be a security problem (to keep viruses from attaching). I am not familiar with the snk and how the dll is signed… does that protect it from modification after it is built to a dll?

    Sincerely,
    Ed
    PS: I am in need of alpha/beta testers… anyone interested, please email me at “pawnslinger@yahoo.com” My program is freely distributed, but so far I haven’t released any source code. Also, if you want to look over my program, it is available thru CNET or my website at “http://myaudiobookreader.com/”

    • You could definitely do as you said and copy the code into your Project.

      Though it does sound like a dll signing issue. It could be as simple as re-creating the key file through the Project properties dialog.

      This article describes how to do that:
      How to: Sign an Assembly (Visual Studio 2005)

      Nice work on your tag library and audio book reader.

  18. Hi Perry:

    Thanks for the link to the signing information. I haven’t had time to go over it in detail yet, but I will. I did some preliminary investigation into it (not thru the link you gave though), and I think I may be somewhat limited in this area, because I am using the Express version. I am not sure, but the Express version is missing some things that are needed to fully publish a project. So I created my own certification methods… they work reasonably well, but are not nearly as strong as the official methods. I just generate an 80 bit certificate, I am thinking of increasing its strength for the next release to keep one step ahead of the malware.

    Sincerely,
    Ed

    • You have an impressive idea to make your own cert, I wouldn’t have thought of that option.

      Here are some more useful links about signing assemblies:
      How to: Sign an Assembly with a Strong Name (.NET Framework 4)
      Strong-Name Signing for Managed Applications (Visual Studio 2010)

      An excerpt from one of the links:

      Strong-name signing, or strong-naming, gives a software component a globally unique identity that cannot be spoofed by someone else. Strong names are used to guarantee that component dependencies and configuration statements map to exactly the correct component and component version.

      A strong name consists of the assembly’s identity (simple text name, version number, and culture information), plus a public key token and a digital signature.

      For Visual C# and Visual Basic projects, Visual Studio enables strong-naming through the Signing pane in the Project Designer; see Signing Page, Project Designer.

      For Visual C++ projects, you use linker options to sign your assembly; see Strong Name Assemblies (Assembly Signing) (C++/CLI).

  19. Hi Perry:

    Just wanted to let you know, I was successful in using your code as a template for adding the APIC frame to my tag library! I changed it up a little bit so that it passes back an array of img… so both images (or possibly more) can be extracted with one call to the library. Thank you for making your code available!

    Sincerely,
    Ed

    • Excellent work! Knowing someone else was able to benefit from my contribution to the world does bring a smile to my face.

  20. Don’t know if you can help me with this or not. I am attempting to use your library in a VFP9 application. I have used Regasm to register the file, but when I attempt to “ad3=CreateObject(“ID3TagLibrary.ComParser”)” I get the error message command contains unrecognized phrase/keyword. Found the following at http://www.sweetpotatosoftware.com/SPSBlog/PermaLink,guid,3dd24f92-a52c-4bb0-8121-c2e6e2cc4f93.aspx about using a net control in a VFP application.

    In your solution’s properties do the following:
    •Checkmark the “Register for COM interop” checkbox on the Build page
    •Checkmark the “Make assembly COM-visible” checkbox in the Assembly Information screen accessible from the Application page (alternately you can just open up the AssemblyInfo.cs file and make sure it says:
    [assembly: ComVisible(true)]

    Any help would be appreciated.

    • Graham, unfortunately I don’t have FoxPro to test this, nor am I very familiar with it. I am pretty sure I checked both of those options when I compiled the libraries.

      From your link, did you see the part where it says to use REGASM to register the ActiveX DLL?

      How to use the ActiveX in Visual FoxPro
      Once you have built your ActiveX control you can then proceed to use it in Visual FoxPro. If you aren’t building the control (which will register the control for COM interop on your system) and just want to use one like I made, you’ll have to register the DLL with REGASM.

      I’ll let you know if I find a solution though. And if you find the solution, please do share it here for others!

    • I got this working in Visual Foxpro 9 by building the solution in Visual Studio 2010 but I had to Run as Adminstrator for it to register correctly. I was then able to read MP3 tags using:

      loMP3 = CreateObject(“ID3TagLibrary.ComParser”)
      lcArtist = loMP3.ParseMP3(“??????.mp3”).Artist

      Hope this helps!

  21. Hello,

    First of all, I love your library.
    However, I have a little problem, same as Jason Knapp. Once I’ve created the object, I can’t find any method « dispose », to release the resources, and I can’t rename the file.
    Can you explaining to me how to do that ?

    Thank you

    • Jackernel, you bring up a good point that is long overdue. There is currently no dispose method for the library, but as you and others have said, it’s probably necessary to have that since files are being locked. Hopefully I can reproduce your problem and eliminate it from the next version of this library. I’m spread a little thin at the moment, so my software updates are coming along slower than usual, but we’ll get there. Thanks for your interest by the way!

  22. Hi fella, great bit of coding. I’m trying to extract the track length.. ie 00:04:23 .. is that possible from this DLL ?

    many thanks for the great coding

    Steve

  23. Why i don’t get information on Editor ? for example Sony music
    Is Editor Tag inside ID3V2 ?

  24. Hi Perry,

    Great library. Thanks for your efforts so far. Are you planning to add support for other ID3 tag fields such as length and albumartist?

    Also, any timescales on a version which will write back the MP3 tags?

    Many Thanks
    Darren

    • The library should give you access to album artist, but length is something outside the scope of ID3 (I might include it in the library though). Tag writing is in the works.

  25. Thank you!

    It works great!

    I got 2 questions.
    The artwork code isn’t working in vb2008 and is it possible to get the song length out of it?

    • Robin, sometimes the song length will be stored in the TLEN frame of the ID3 tag, which my library can access, but only if the person who ripped the song/produced the ID3 tag cared enough to include the TLEN frame for that particular file. Unfortunately, most of the time you will not find a TLEN frame, so you’ll need to use a different method (other than the ID3 tag) to read the song length. Song length is commonly found in the file description (meta) which is why you can easily tell the length by looking at the file properties in Windows, so using a Windows API (such as Multimedia API) we should be able to read the length. In the future I hope to include this helper function.

      To grab the TLEN frame, or any frame from the ID3 tag, you could try the following:

      myFile.Tag2.GetFrameValue("TLEN")
      

      I use VS2008 as well and I haven’t noticed any problem with the artwork code. Could you please elaborate on what happens when you try to use it?

  26. Thank you for the fast reply!

    I got this error in vb 2008:

    Error	1	Argument not specified for parameter 'argFrameSize' of 'Public Function Artwork(argFrameSize As Integer) As System.Drawing.Image'.
    
    • I used this code:

      PictureBox1.Image = mp3.Tag2.Artwork
    • Sorry about that, I really should fix up the Artwork() functions. My example in the article is incorrect so I’ll need to fix that too.

      Currently the way you will have to get the artwork is by using the Artwork2() function.

      Since ID3 tags could contain more than one APIC frame, you need to pass a frame index number to the function. You can iterate through the frames to find the index number for the APIC frame in question. Example:

      Dim myIndex as Integer
      ' scan through the frames and find the first APIC/PIC frame
      For Each mFrame As FrameBase In mp3.Tag2.Frames
          If mFrame.ID = "APIC" Or mFrame.ID = "PIC" Then
              myIndex = mFrame.Index
              Exit For
          End If
      Next
      PictureBox1.Image = mp3.Tag2.Artwork2(myIndex)
      

      Hope that helps. I’ll publish an update to this library which should fix the Artwork() functions in the next few days.

    • The “FrameBase” is not defined. Can you fix?

  27. I think I got the worst problem here. I am not able to see the id3 inside the project tab when I am adding reference. What am I lacking?

  28. Hello,

    Thx for this library. I ran the regasm command with no problem, but when I run the vbs file, I get this error:
    “ActiveX Component can’t create Object: ‘ID3TagLibrary.ComParser’
    Code: 800A01AD
    Source: Microsoft VBScript runtime error”

  29. Thank you!
    This was the only VB library that I could understand how to use it. Reading works perfectly.
    But is there any news on the tag writing? I’ve tried other libraries (no luck), but this one is so simple!

  30. First of all, thanks for the awesome library. I too came across the bug when retrieving the album art. Managed to avoid it using your workaround posted above.

    “Currently the way you will have to get the artwork is by using the Artwork2() function.”

    Although in my case Artwork() function worked for me. Not the Artwork2(). Just thought of letting you and other who may come across my problem know.

    Cheers!

    • Thanks for the tip nKode. The artwork is surely half-broken and I didn’t know that at the time of releasing the current version. Though my time has been limited recently, I haven’t forgotten about this issue or the tag writing feature. We’ll get there eventually 🙂

  31. Hello This seems like an awesome library but I am getting a blank entry in the message box while using your code on Form Load. I have no idea what I am doing wrong.

  32. Arthur van Lokhorst says:

    Hello Perry,

    I came upon your project because it is mentioned on the website of id3.org
    (http://www.id3.org/Implementations), which, I suppose, is an honor. Thank you very much for making your library available to all. I was up and running within an hour. This is how I coded it in C#:

    // create an mp3 object
    ID3TagLibrary.MP3File mp3 = new ID3TagLibrary.MP3File(fullfilename);
    // fill some text boxes
    txtArtiest.Text = mp3.Artist;
    txtTitel.Text = mp3.Title;
    txtGenre.Text = mp3.Genre;
    txtAlbum.Text = mp3.Album;
    // grab image (by iterating over the frames)
    foreach (ID3TagLibrary.ID3v2Tag.FrameBase frame in mp3.Tag2.Frames)
    {
    if ((frame.ID == “APIC”) || (frame.ID == “PIC”))
    {
    // put picture in image box on the form
    pictureBox1.Image = mp3.Tag2.Artwork(frame.Index));
    // stop iterating over frames
    break;
    }
    }
    // done

    (In practice, you would like to scale the image to your pictureBox. For the sake of simplicity I omitted that part).

    As for the wishlist:

    When a picture is large, winmm.dll (the Windows Media Control) fails (when I pass it the command “play”). However, you can pass it the command “play from xxx”, where xxx is the start position of the usable part of your file (or any other part, e.g. if you would like to fast forward your mp3). I suppose that would do the job. However, to issue the command “play from xxx”, one needs to know the offset. If you could incorporate a function in your library that would retrieve the offset, I would be very grateful.

    Kind regards, and thanks so much,
    Arthur van Lokhorst
    Netherlands

    • Thanks for posting your comment. I am the one who added my library to id3.org so there’s no honor there 🙂 Development has been inactive for a while but I will revisit this project to incorporate some needed updates and fixes. I don’t know exactly when I’ll be able to do that yet.

  33. Perry you have successfully helped me figure this ID3 tag stuff out completely! PROPS! and THANK YOU SO MUCH!!!!

  34. Nick Thomas says:

    Hi,
    I want to try to use this in an old Visual Studio 6.0 project.
    Using MFC and C++.

    I can load the dll using:

    m_hInstLibrary = LoadLibrary(“ID3TagLibrary.dll”);
    if (m_hInstLibrary == NULL)
    {
    FreeLibrary(m_hInstLibrary);
    MessageBox(“LoadLibrary Failed!”);
    exit(1);
    }

    But, I can’t access the internal functions.
    Is this because it’s a VB DLL ?

    Thanks in advance.

  35. Hi there I’m using your Tag Library in Visual Studio 2010, and I’m having some difficulty getting documentation on VB scripts to import the Album Artwork (.jpg)
    I used the example script on the top of this page, but it gives me an error saying that

    PictureBox1.Image = myMp3.Tag2.Artwork

    says Argument Not Specified for Parameter ‘argFrameSize’ of ‘PublicFunctionArtwrok(argFrameSize as Integer) As System.Drawing.Image’

    I’ve been trying for days to figure this out and I cant find any legitimate Vb code . I gave up on UltraId3Lib for this task.

    Can I get a full TO DO list and/or sample code to just get the album artwork in Vb.net 2010?? Please and Thank you

  36. Mikiwi93 says:

    If i want write the title and the artist,how can i do it?

  37. Martin van Iersel says:

    Hi Perry, love your ID3 Tag Library its been the easiest to use out of the ones ive seen and works great.
    The only problem i am having is reading the album art, Ive tried the following code
    Dim myIndex as Integer
    ‘ scan through the frames and find the first APIC/PIC frame
    For Each mFrame As FrameBase In mp3.Tag2.Frames
    If mFrame.ID = “APIC” Or mFrame.ID = “PIC” Then
    myIndex = mFrame.Index
    Exit For
    End If
    Next
    PictureBox1.Image = mp3.Tag2.Artwork2(myIndex)
    But VB moans about FrameBase , what am is it missing.

    Thanks

    • Glad you found the library useful! You might try prefixing the namespaces if you didn’t “import” it at the top of your Form:

      For Each mFrame as ID3TagLibrary.ID3v2Tag.FrameBase in mp3.Tag2.Frames
      
      Next
      

      Anyhow I have a new version in the works that will be much better. It can easily differentiate between multiple artworks in one tag, and no need to loop through all frames to find them because a FindFrames() function will give you just the frames that match your FrameType (a new property). The next version also reads both ASCII and UNICODE frames, and will have tag writing capability.

  38. Martin van Iersel says:

    Thanks Perry,

    That worked, I have noticed some MP3’s created in Itunes the title doesnt matter which tag I use, is that an MP3 would that be an Itunes MP3 file glitch

  39. Marc Youth says:

    I’m very excited to start using your library. I keep getting the error message ActiveX Component can’t create object. Do you have any idea what could be causing that? I tried installing the .dll under ActiveX and that wouldn’t work. I did set it up in the references dialog.

    Thanks for your help.

  40. hi there !
    i just tried your app and like it, but it doesn’t read the length for every song 🙁 i guess you are reading specific data sector in which this data is supposed to be.

  41. Hello !
    Can you explain me how i can get the ID3-Cover and save it to a folder ?
    I´m using the .NET Framework 4.0 !

  42. I’m trying to use your code in Access 2007, but when I run the example, I get the following error:
    Run-time error ‘429’:
    ActiveX component can’t create object
    when it hits this line:
    Set myParser = New ID3TagLibrary.ComParser

    Any advice?

    Thanks!

    • Roy Corneloues says:

      I’m getting the same thing in Access 2010.

      Been looking for a id3 library to link in to an Access application for a while. Stumbled on this today and thought my prayers had been answered as the .tlb was referenced fine.

      But I too get the 429 error…

      Any advice would be good.

      Cheers,

      Roy

    • Roy Corneloues says:

      BTW,

      I have tried both

      Dim mp3Parser As New ID3TagLibrary.ComParser

      As well as:

      Dim mp3Parser As ID3TagLibrary.ComParser
      Set mp3Parser = CreateObject(“ID3TagLibrary.ComParser”)

      They both give the same error

  43. Please help…

    I have gotten some stuff working using VBScript, specifically, I can read the Artist, Album, Title, Genre, and Comment fields. I haven’t been able to figure out the names I’m supposed to use for the other fields, Mainly:

    TrackNumber
    AlbumArtist
    Year
    BPM
    ContentGroup
    Composer
    Compilation
    AlbumArtistSort
    AlbumSort

    Are these fields supported? If so, what names do I use?

    Thanks

  44. Roger Rabbit says:

    Any news about your progress?
    Do you have roadmap when we can use the possibility to write id3tags?

  45. i dont understand how to put artwork on vb

  46. Mukesh Bhargava says:

    Hi,

    Nice Library My Q. is that How can I Display Lyrics of Mp3 Song in my Application using the same.

    Thanks

    • My lyrics were stored in frame USLT.

      In vb.net i added lyrics to a textfield simply using taginfo.Tag2.GetFrameValue(“USLT”).

      txt_lyrics.text = taginfo.Tag2.GetFrameValue(“USLT”)

  47. Hello, I have 1 questions about your ID3Library dll.
    fonts? no recognisse ä, ü, ö?
    What i must do?

  48. I’ve been reading through the comments, and i’m just a little confused on one thing.

    How do i go about disposing the file after reading from it? I too creating a simple renaming tool that uses the tag information to construct a filename.

    Everything works great, but i can’t rename the file as it seems to be in use. In the comments something is mentioned about READER.CLOSE or something, but i don’t quite know what that is about.

    Also worth mentioning is that the year tag doesn’t seem to work for me… kinda. Id3V1 year tag will be read, but not from id3v2. however the framevalue(“TYER”) seems to load the year flawlessly.

    Again, this is fantastic. Don’t know how long i screwed around with mp3 tagging crap before this beauty was found.

    • Michael, thanks for checking out the library. You’re probably correct, the current version may not be releasing resources. I have a new version that might fix this problem, which has been getting dusty on my hard drive for almost a year. I simply don’t have the time right now to wrap up testing on it for a new version release. It does handle tags better, especially album artwork. Interested in trying it out?

  49. Wasn’t expecting a reply for some time…

    Yes i am interested. To be honest i haven’t tried accessing many of the tags, and those i have have worked perfectly. I also have my own media player that i plan to use this on, and it will require many more tag fields, so i’m about to start testing this more thoroughly.

    The inability to dispose of mp3s is at most an inconvenience, but i’ve worked around it with no irritation.

    I believe i was reading that at the moment editing of tags is not a feature – though you’ve been working on it. That is currently the only thing that i feel is really missing from this (though my testing is still limited :P)

    All in all, this has been extremely useful for me, and again i thank you for making it.

    • Ok just looked into a bit more. Looks like i can easily access every tag i’m aware of, including album art, without any problem. I’ll test with more files.
      I may need the frame ID to easily use them, but your Tag Viewer makes them clear, so no problem.

      I’ve successfully loaded about 16 different tags, including artwork and lyrics. Everything winamp can display this can to.
      Only thing missing for me is the ability to write ID3 tags.

  50. Nuno Soares says:

    Hello, I think that a field that is missing is the track number.
    How do I get the length of the song in the tag?

    • Track number does work. I access it from .Tag2.TrackNumber.
      As for the length of the song – i’m pretty sure that is not included in the id3tag. Media players will get this value in many ways, but i think i’ve done so in the past by obtaining it through accessing the file properties of the file. Windows stores the length there.

Leave a Reply

Your email address will not be published. Required fields are marked *