Question

I'm working on a HTML5 (no flash) SHOUTCast client. For some streams, I can set an <audio> tag's src to the MP3 stream and it plays just fine.

But there is one stream that doesn't work that way. This is because the URL for the stream is the same as the steam's index.html page. It uses the User-Agent. If it's a browser, you get an HTML page; if it's not, you get an MP3 stream.

So, how can I edit the request headers sent by the browser when requesting the resource for the <audio> tag? I don't want it to send the User-Agent.

Was it helpful?

Solution

I don't think there's a way to change the User-Agent. But you can force SHOUTcast to serve the stream by adding a Semicolon ; to the end of the URL. SHOUTcast will then ignore the User-Agent.

HTML5 example:

<!DOCTYPE html>
<html>
  <body>
    <audio controls>
      <source src="http://72.13.82.82:5100/;"/>
      <em>Sorry, your browser doesn't support HTML5 audio.</em>
    </audio>
  </body>
</html>

You can also verify the workaround by visiting http://72.13.82.82:5100/; directly in browser. You should see some ICY-metadata followed by the mpeg stream.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top