Display an image when stream is online

The following example demonstrates how to display an image when a stream broadcast is online

<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script type="text/javascript">
var onlineUrl = 'https://your-website/online.png';
var offlineUrl = 'https://your-website/offline.png';
$.getJSON("https://demo.mediacp.net/json/stream/icecast2-ssl", function(data){
$("#status-img").attr('src', data.status ? onlineUrl : offlineUrl);
});
</script>
<img id="status-img" src="https://your-website/offline.png">
  • 1 Users Found This Useful
Was this answer helpful?