Copyright © 2001-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 
GetMp3TagVersion obtains the tag version for a MP3 song 
GetMp3Tag1Field retrieves a specific field of an ID3V1 tag for a MP3 song 
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: the buffer allocation is responsibility of the container which can obtain the buffer size calling the GetMp3Tag2Size
Below you can find a couple of samples that demonstrate how to retrieve a ID3V2 tag in Visual Basic 6 and Visual C++ 6: 
 
Visual Basic 6 
 
Private Sub Command1_Click() 
   Amp3dj1.LoadSound 0, "mysong.mp3" 
   Amp3dj1.ReadSoundInfo 0 
   If Amp3dj1.IsTagAvailable(0, TAGTYPE_ID3V2) = 0 Then 
       Amp3dj1.CloseSound (0) 
       Exit Sub 
   End If 
    
   Dim ntagSize As Long 
   ntagSize = Mp3play1.GetMp3Tag2Size(0) 
    
   Dim pBuffer() As Byte 
   ReDim pBuffer(ntagSize) 
   Amp3dj1.GetMp3Tag2Data 0, pBuffer, ntagSize 
 
       ...  
       use of the tag contents 
       ... 
    
End Sub 
 
 
Visual C++ 6 with MFC 
 
void CReadId3v2Dlg::OnButton1()  
   m_player.LoadSound (0, "mysound.mp3"); 
   m_player.ReadSoundInfo (0); 
   if (m_player.IsTagAvailable (0, TAGTYPE_ID3V2) == 0) 
   { 
       m_player.CloseSound (0); 
       return; 
   } 
 
   long nTagSize = m_player.GetMp3Tag2Size (0); 
   if (nTagSize == 0) 
   { 
       m_player.CloseSound (0); 
       return; 
   } 
 
   BYTE *pTagBuffer = new BYTE[nTagSize]; 
 
   COleVariant var; 
   var.vt = VT_BYREF | VT_UI1; 
   var.pbVal = pTagBuffer; 
   m_player.GetMp3Tag2Data (0, var, nTagSize); 
 
       ...  
       use of the tag contents 
       ... 
 
   delete pTagBuffer; 
 
 
 
 
 
 
 
 
Copyright © 2001-2008 MultiMedia Soft 
Return to Table of contents