Search code examples
.nethttpmp3audio-streamingshoutcast

How can I record online radio in .NET?


I did see this question but not much on .NET...

I want to write .NET code to connect to a web server streaming SHOUTcast (Winamp) audio content (if anyone is interested, the URL is http://live.radiotrinitas.ro:8000/) and record it.

But I don't know much how to do it.

Just open the HTTP connection, and stream it off to a file on the disk?

There are some headers that appear to be in the content (or so it seems to me) and I don't know what the format is so how to name the extension of the file (MP3?)


Update1 :

I did try to connect using HttpWebRequest but it throws up saying ProtocolViolation. Then I tried connecting using TcpClient and it doesn't send back anything. I guess it awaits some starting command. I don't know this, apparently proprietary (?), protocol...


Solution

  • Well it seems someone over CodeProject posted something useful and working!

    http://www.codeproject.com/KB/audio-video/SHOUTcastRipper.aspx

    To run the code snippet you need to set the following configuration :

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
      <system.net>
        <settings>
          <httpWebRequest useUnsafeHeaderParsing="true"/>
        </settings>
      </system.net>
    </configuration>