Meet us at PRINT 19. Chicago, IL. Oct. 3 - 5.
This documentation is for the old version. Go to the latest Graphics Mill docs

Reading ID3 Tags

Reading audio files metadata is a very frequent task. Suppose, you are making a Web site for publishing MP3 files. Of course, it is preferable to have the information about performers, titles, and so on extracted automatically. Let us see how to do it using Media Processor Add-on.

The function that will read ID3 fields should perform the following operations:

  1. Create a WMReader reader and open the source file.
  2. If necessary, check that the reader supports metadata extraction.
  3. Get the field collection and iterate through it, processing its entries.
  4. Close the reader.

The following example simply prints the content of each ID3 field, but if you need, you can modify the code to fit your needs. For example, it can return a collection of all or only required values.

Visual Basic
Public Sub PrintID3(ByVal inputFilename As String)
        'Create the reader
        Dim reader As WMReader = New WMReader(inputFilename)
            Dim id3 As MediaProcessorMetadataDictionary = reader.Metadata
        Console.WriteLine("*** Extracted ID3 fields:")
        'Iterate through all fields
        For Each key As Object In id3.Keys
        'Print synchronized lyrics
            If key = MediaProcessorMetadataDictionary.SynchronizedLyrics Then
                Console.WriteLine(id3.GetKeyDescription(key) + ":")
                Dim lyrics As ID3SynchronisedLyrics = CType(id3(key), _
                For Each lkey As Object In lyrics.Keys
                    Console.WriteLine("\t" + lyrics(lkey).ToString())
                'Save the attached picture as a file
            ElseIf key = MediaProcessorMetadataDictionary.AttachedPicture Then
                Console.WriteLine("Contains an attached picture: " + _
                 inputFilename + ".gif")
                Dim image As Aurigma.GraphicsMill.Bitmap = CType(id3(key), _
                image.Save(inputFilename + ".gif")
                'Print other fields
                Console.WriteLine(id3.GetKeyDescription(key).ToString() + ": " _
                 + id3(key).ToString())
            End If
    Catch ex As Exception
    End Try
End Sub
public static void PrintID3(string inputFilename)
        //Create the reader
        WMReader reader = new WMReader(inputFilename);
        MediaProcessorMetadataDictionary id3 = reader.Metadata;
        Console.WriteLine("*** Extracted ID3 fields:");
        //Iterate through all fields
        foreach (System.Object key in id3.Keys)
            //Print synchronized lyrics
            if (key.Equals(MediaProcessorMetadataDictionary.SynchronizedLyrics))
                Console.WriteLine(id3.GetKeyDescription(key) + ":");
                ID3SynchronisedLyrics lyrics =
                foreach (System.Object lkey in lyrics.Keys)
                    Console.WriteLine("\t" + lyrics[lkey].ToString());
            //Save the attached picture as a file
            else if (key.Equals(MediaProcessorMetadataDictionary.AttachedPicture))
                Console.WriteLine("Contains an attached picture: " +
                    inputFilename + ".gif");
                Aurigma.GraphicsMill.Bitmap image =
                image.Save(inputFilename + ".gif");
            //Print other fields
                Console.WriteLine(id3.GetKeyDescription(key).ToString() +
                    ": " + id3[key].ToString());
    catch (System.Exception ex)

See Also