I'm trying to play mp3 shoutcast stream radio stations with HTML5 audio.
I don't think it will be relevant but here is the code anyway:
var player = new Audio();
player.autobuffer = true;
player.src = "http://173.192.48.71:9048/;";
player.volume = 1;
player.play();
Shoutcast detects that request comes from browser and returns radio status page, so I put ";" at the end of stream which forces server to return audio stream instead of status page. This works fine in Chrome and Safari, but not in Firefox.
Firefox for some reason detects this as text/plain content and refuses to play it with this error:
HTTP "Content-Type" of "text/plain" is not supported.
Load of media resource http://173.192.48.71:9048/; failed.
I used Fiddler to inspect what is being sent from shoutcast server and it clearly states "content-type: audio/mpeg". Is there any way to force Firefox to play the shoutcast stream with HTML5 audio?
ICY-*
headers won't affect anything. The error message is either misreported, or there is a bug in your where somehow you are loading a different URL. (I doubt it is a bug, as if you hit any other endpoint on that server, you would gettext/html
instead.) – Laundrytext/plain
content-type, so yes, ICY headers make the world of difference here. See my answer below. – SelaginellaICY
in the status line... yes, that makes sense. I was referring to the actualICY-MetaInt
headers and what not. – Laundry