Introduction
This is only a raw solution to grab a SHOUTcast stream from a server.
Using the code
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
SHOUTcast_Save("http://192.168.168.97:80/stream/2001", "c:\song_raw.mp3")
End Sub
Public Function SHOUTcast_Save(ByVal sURL As String, _
ByVal sFileName As String) As Boolean
Dim webreq As System.Net.HttpWebRequest = _
CType(System.Net.WebRequest.Create(sURL), _
System.Net.HttpWebRequest)
webreq.Headers.Clear()
webreq.Headers.Add("GET", "/stream/2001 HTTP/1.0")
webreq.UserAgent = "WinampMPEG/5.09"
webreq.Headers.Add("Icy-MetaData", "1")
Dim webres As System.Net.WebResponse = webreq.GetResponse()
Dim oReader As System.IO.Stream = webres.GetResponseStream()
Dim oFile As System.IO.Stream = New System.IO.FileStream(sFileName, _
System.IO.FileMode.OpenOrCreate, _
System.IO.FileAccess.ReadWrite, System.IO.FileShare.None)
For Each oHeader As System.Net.WebHeaderCollection In webres.Headers
Next
Dim b As Integer
While True
b = oReader.ReadByte()
If b = -1 Then Exit While
oFile.WriteByte(Convert.ToByte(b))
End While
oReader.Close()
oFile.Close()
End Function
//
Points of Interest
You see, that the metadata is not parsed. (This means you must not write all bytes.) Good Luck... :)
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.