How to retrieve basic TAG information from the sound loaded into a player
This tutorial refers to a set of methods which, although still of some usage, are now mostly superseded by methods described inside the How to read TAG information in sound files tutorial.
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
GetFileTagField retrieves a specific field inside the tag
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 ReadSoundInfo2 method.
If the GetFileTagField method succeeds in retrieving the artist name and the title of the song, you can try requesting the related lyrics text through the SoundLyricsRequest method: this request will try to connect to the MultiMedia Soft server in order to check for availability of the requested lyrics text: when the request has been completed and after receiving the SoundLyricsAvailable event with a positive result, you can retrieve the lyrics text through the SoundLyricsGet method.
In a similar way, after having obtained information about the artist name and the title of the album, there is the possibility to obtain the cover art of the related Audio CD (see the How to get Audio CD info using CDDB servers and Amazon catalogue tutorial for details) and then to directly navigate to the purchase page of the specific Audio CD on the Amazon store through the CdNavigateToPurchasePage 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 an ID3V2 tag in Visual C#
private void buttonId3v2_Click(object sender, System.EventArgs e)
audioDjStudio1.LoadSound (0, "mysound.mp3");
// check if tag ID3V2 is available
if (audioDjStudio1.IsTagAvailable (0, TAGTYPE_ID3V2) == 0)
// get the the tag's length in bytes
long nTagSize = audioDjStudio1.GetMp3Tag2Size (0);
if (nTagSize == 0)
// allocate the memory buffer
byte byteBuffer = null;
byteBuffer = new byte[nTagSize];
// the "unsafe" code below can be enabled by setting the "Allow unsafe code blocks" property to "True"
// inside the project properties
fixed (void* vpBuf = byteBuffer)
// obtain the tag contents
if (audioDjStudio1.GetMp3Tag2Data (0, (Int32) vpBuf, (Int32) nTagSize) == enumErrorCodes.NOERROR)
// use of the tag contents
A sample of access to tag information in Visual C# and Visual Basic.NET can be found inside the following sample installed with the product's setup package: