This is my VB code for metadata extraction (found on the net and modified by me).
Could be useful?
Public Sub Title(ByVal testo As String)
Dim server As String = AxWindowsMediaPlayer1.URL
Dim request As HttpWebRequest = Nothing
Dim _response As HttpWebResponse = Nothing
Dim metaInt As Integer = 0 ' blocksize of mp3 data
Dim count As Integer = 0 ' byte counter
Dim metadataLength As Integer = 0 ' length of metadata header
Dim metadataHeader As String = "" ' previous metadata header, to compare with new header and find next song
Dim buffer As Byte() = New Byte(511) {} ' receive buffer
Dim socketStream As Stream = Nothing ' input stream on the web request
Dim byteOut As Stream = Nothing ' output stream on the destination file
Dim subst As String
request = DirectCast(WebRequest.Create(server), HttpWebRequest) ' create web request
request.Headers.Clear() ' clear old request header and build own header to receive ICY-metadata
request.Headers.Add("Icy-MetaData", "1") 'request.Headers.Add("GET", serverPath + " HTTP/1.0");
request.UserAgent = "WinampMPEG/5.09" ' needed to receive metadata informations
Try ' execute request
_response = DirectCast(request.GetResponse(), HttpWebResponse)
Catch ex As Exception
TitleTextBox.Text = "NOT AVAILABLE"
Return
End Try
metaInt = Convert.ToInt32(_response.GetResponseHeader("icy-metaint")) ' read blocksize to find metadata header
Try
socketStream = _response.GetResponseStream() ' open stream on response
While True ' rip stream in an endless loop
Dim bufLen As Integer = socketStream.Read(buffer, 0, buffer.Length) ' read byteblock
If bufLen < 0 Then
Return
End If
For i As Integer = 0 To bufLen - 1 ' if there is a header, the 'headerLength' would be set to a value != 0. Then we save the header to a string
If metadataLength <> 0 Then
metadataHeader += Convert.ToChar(buffer(i))
metadataLength -= 1
If metadataLength = 0 Then
Exit While
End If
Else
If System.Math.Max(System.Threading.Interlocked.Increment(count), count - 1) < metaInt Then ' write mp3 data to file or extract metadata headerlength
If byteOut IsNot Nothing Then ' write bytes to filestream
byteOut.Write(buffer, i, 1) ' as long as we don't have a songtitle, we don't open a new file and don't write any bytes
If count Mod 100 = 0 Then
byteOut.Flush()
End If
End If
Else
metadataLength = Convert.ToInt32(buffer(i)) * 16 ' get headerlength from lengthbyte and multiply by 16 to get correct headerlength
count = 0
End If
End If
Next
End While
Dim numberString As String = String.Empty
Dim str2 As String = ""
Dim numberString2 As String = String.Empty
If metadataHeader.Contains("'") Then
numberString = metadataHeader.IndexOf("'")
numberString2 = metadataHeader.IndexOf(";")
subst = metadataHeader.Substring(numberString + 1, numberString2 - numberString - 2)
TitleTextBox.Text = subst
Else
TitleTextBox.Text = "NOT AVAILABLE"
End If
Catch ex As Exception
TitleTextBox.Text = "NOT AVAILABLE"
Finally
If byteOut IsNot Nothing Then
byteOut.Close()
End If
If socketStream IsNot Nothing Then
socketStream.Close()
End If
End Try
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
TextBoxBr.Text = (_response.Headers("icy-br"))
TextBoxWeb.Text = (_response.Headers("icy-url"))
TextBoxGenre.Text = (_response.Headers("icy-genre"))
TextBoxName.Text = (_response.Headers("icy-name"))
End Sub