Copyright © 2005-2019 MultiMedia Soft

GetMp3Tag2Data method

Previous pageReturn to chapter overviewNext page

Remarks

 

Retrieves the full binary contents of the ID3V2 tag for a MP3 sound. The overall tag size can be obtained through a call to the GetMp3Tag2Size method.

 

Details about the use of Tags and a sample of use of this method can be found on the How to read TAG information in sound files and How to retrieve basic TAG information from the sound loaded into a player tutorials.

 

 

Syntax

 

[Visual Basic]

Public Function GetMp3Tag2Data (

nPlayerIndex as Int16,

pBuffer() as Byte,

nBufferLength as Int32

) as enumErrorCodes


 

[C#]

public enumErrorCodes GetMp3Tag2Data (

Int16 nPlayerIndex,

byte [] pBuffer,

Int32 nBufferLength

);


 

[C++]

public: enumErrorCodes GetMp3Tag2Data (

Int16 nPlayerIndex,

unsigned char __gc[] pBuffer,

Int32 nBufferLength

);


 

 

 

Parameter

Description

 

 

nPlayerIndex

Number representing the zero-based index of the involved player

pBuffer

Destination buffer that will receive binary data. Allocating/freeing this buffer is responsibility of the container application.

nBufferLen

Length in bytes of the destination buffer

 

 

Return value

 

Value

Meaning

 

 

Negative value

An error occurred (see the LastError property for further error details)

enumErrorCodes.NOERROR (0)

The method call was successful.

 

 

Sample

 

Below you can find a couple of samples that demonstrate how to load into a memory buffer the ID3V2 tag contents in Visual Basic.NET and Visual C# .

 

Visual Basic.NET

 

' declare the memory buffer (cannot be a local variable)

Dim m_byteBuffer() As Byte

 

Private Sub ButtonReadTag_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

 ' load sound and obtain info

 AudioDjStudio1.LoadSound(0, "c:\mp3_sounds\bb.mp3")

 AudioDjStudio1.ReadSoundInfo2(0)

 

 ' check if the ID3V2 tag is available

 If AudioDjStudio1.IsTagAvailable(0, AudioDjStudio.enumTagTypes.TAGTYPE_ID3V2) > 0 Then

     ' get the tag size in bytes

     Dim nTagLength As Int32

     nTagLength = AudioDjStudio1.GetMp3Tag2Size(0)

 

     ' allocate the receiving buffer

     ReDim m_byteBuffer(nTagLength)

 

     ' read tag data

     AudioDjStudio1.GetMp3Tag2Data(0, m_byteBuffer, nTagLength)

 

     ' now you could parse tag data

     ' .

     ' .

     ' .

 End If

End Sub

 

 

Visual C#.NET

 

// declare the memory buffer (cannot be a local variable)

byte[] m_byteBuffer = null;

 

private void buttonReadTag_Click(object sender, System.EventArgs e)

{

 // load sound and obtain info

 audioDjStudio1.LoadSound (0, "c:\\mysound.mp3");

 audioDjStudio1.ReadSoundInfo2 (0);

 

 // check if the ID3V2 tag is available

 if (audioDjStudio1.IsTagAvailable (0, enumTagTypes.TAGTYPE_ID3V2) > 0)

 {

     // get the tag size in bytes

     Int32  nTagLength = audioDjStudio1.GetMp3Tag2Size (0);

 

     // allocate the receiving buffer

     m_byteBuffer = new byte[nTagLength];

 

     // read tag data

     audioDjStudio1.GetMp3Tag2Data (0, m_byteBuffer, (Int32) nTagLength);

 

     // now you could parse tag data

     // .

     // .

     // .

 }

}