Copyright © 2005-2008 MultiMedia Soft 
Return to Table of contents  
 
How to retrieve TAG information 
 
Many formats add some information, also known as Tags, to the song binary in order to allow an immediate identification of the file contents: the availability of this information and its contents can be retrieved using the following methods: 
 
IsTagAvailable determines if a certain type of tag is contained inside the song binary 
GetTagString retrieves a string inside the tag 
 
Note that, in order to speed up the sound file loading, tag information is not available immediately after the call of the LoadSound method: once the sound is loaded, you can force the control to read tag information using the ReadSoundInfo method. 
 
If dealing with playlists, you can use the PlayListGetItemString method in order to receive a string containing the needed information. 
 
Usually tags are internally implemented as concatenated strings: the only exception is the ID3V2 tag format used by MP3 songs: this format is far more complex because allows the use of binary data. Specifications about this tag format can be found on the ID3V2 official web site
Due to the ID3V2 format complexity, our control will give the possibility to retrieve the full tag binary content but will not give information about the single elements inside the tag; for this purpose we have implemented the following methods: 
 
GetMp3Tag2Size retrieves the size of the ID3V2 tag for a MP3 sound 
GetMp3Tag2Data retrieves the full binary contents of the ID3V2 tag for a MP3 sound 
 
Note that the GetMp3Tag2Data needs to receive from its container a memory buffer that will be filled with the tag binary contents: the buffer allocation is responsibility of the container which can obtain the exact size for the buffer allocation calling the GetMp3Tag2Size method. 
Below you can find a code snippet that demonstrates how to retrieve a ID3V2 tag in Visual C# 
 
 
private void buttonId3v2_Click(object sender, System.EventArgs e)  
   audioDjStudio1.LoadSound (0, "mysound.mp3"); 
   audioDjStudio1.ReadSoundInfo (0); 
 
   // check if tag ID3V2 is available 
   if (audioDjStudio1.IsTagAvailable (0, TAGTYPE_ID3V2) == 0) 
   { 
       audioDjStudio1.CloseSound (); 
       return; 
   } 
 
   // get the the tag's length in bytes 
   long nTagSize = audioDjStudio1.GetMp3Tag2Size (0); 
   if (nTagSize == 0) 
   { 
       audioDjStudio1.CloseSound (0); 
       return; 
   } 
 
   // allocate the memory buffer 
   byte[] byteBuffer = null; 
   byteBuffer = new byte[nTagSize]; 
 
   // the "unsafe" code below can be enabled setting the "Allow unsafe code blocks" property to "True" 
   // inside the project properties 
   unsafe 
   { 
       fixed (void* vpBuf = byteBuffer) 
       { 
           // obtain the tag contents 
           if (audioDjStudio1.GetMp3Tag2Data (0, (Int32) vpBuf, (Int32) nTagSize) == enumErrorCodes.NOERROR) 
           { 
               // use of the tag contents 
               // ... 
          } 
      } 
   } 
 
 
 
 
 
 
 
 
Copyright © 2005-2008 MultiMedia Soft 
Return to Table of contents