Is it possible to play a shoutcast/icecast stream using HTML5?
If so, how should I implement it?
Just navigate your web browser to host/port the Icecast server is listening on. If you are a Windows user, make sure you started the Icecast server and then click on the shortcut in the Startmenu, it will open the Icecast status page in your browser.
Go to the Media Library tab, select Online Services, and choose SHOUTcastRadio. Choose a radio station from the SHOUTcast Radio progressive menus or search for a specific station. To listen to a station, click Tune IN. Bookmark the stations you like so that you don't have to search for them again.
To stream audio or video to Icecast using VLC you need to first ensure you have the right module installed. If you are using Linux you will need to download the latest source code and install VLC with the shout module. To install this module in Linux you will need to configure VLC with the --enable--shout parameter.
Configuring Icecast To be able to stream video, we need to adapt the config a little bit, so that the Icecast buffer for our video stream will be large enough to hold enough data. This can be done either globally for all mountpoints, which is appropriate if you only plan to stream video with this Icecast instance.
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With