Is it possible to play a shoutcast/icecast stream using HTML5?
If so, how should I implement it?
Modern browsers don't need any special treatment or server-side workarounds to play audio. Simply use an audio tag with a direct link to one or more stream sources (not a playlist):
<audio>
<source src="http://relay.publicdomainradio.org/classical.mp3" type="audio/mpeg">
</audio>
From MDN:
The HTML
<audio>
element is used to embed sound content in documents. It may contain one or more audio sources, represented using thesrc
attribute or the<source>
element: the browser will choose the most suitable one.
Browsers support flac
, mp3
, vorbis
, aac
, opus
and wav
. More details on caniuse.com.
Add a semicolon to the end of the http request. It IS the protocol set forth by shoutcast to override it's browser detection. Like this:
<audio controls src="http://shoutcast.internet-radio.org.uk:10272/;"></audio>