Question

We built an internet radio streamer utilizing an icecast server streaming MP3 to Firefox via html5 audio tag. However, sometimes the streamer will stop for whatever reason (disconnection, etc) and when you restart the streamer, it begins streaming from the beginning of the session, which leads us to believe that its playing what is in the browser cache.

The only way to get streamer to play the actual live stream is to delete the history in Firefox. This doesn't happen in other browsers. This also happens if using the flash fallback instead of the html5 audio tag.

Thought about using the following script but didn't think it would apply to this scenario.

<meta http-equiv="Cache-control" content="no-cache" />

Any insight would be helpful. Thanks.

Was it helpful?

Solution

Note: See @MosheL's answer for a modern solution.

Old Answer (and probably still needed for SHOUTcast):

I've found that with SHOUTcast/Icecast streams, the only way to guarantee that you won't be playing from cache is to use the old method of adding a cache-busting URL parameter.

If your original stream URL is this:

http://1.2.3.4/someMountPoint

Then use JavaScript to generate a URL like this when playing:

http://1.2.3.4/someMountPoint?nocache=123456789

This ensures that caching will not happen, as to the browser, they are different resources.

OTHER TIPS

icecast.xml

 <http-headers>
    <header name="Cache-control" value="no-cache" />
</http-headers>

Update (3/2020): on Chrome we need to solve one more problem with buffering live streams:

<audio controls preload="false" autoplay="false" .....
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top