I’m trying to set up my website to display my stream when I’m live and to display something else when I’m not. I currently have the following working:
<script>
$.getJSON('https://api.twitch.tv/kraken/streams/mychannel?client_id=myclientid', function(channel) {
if (channel["stream"] == null) {
$(".online").hide();
$(".offline").show();
} else {
$(".offline").hide();
$(".online").show();
}
});
</script>
It works, however it doesn’t seem to update for a couple minutes or so after I go live or stop streaming. Is there a way to make this more responsive? It doesn’t need to be instant but more than 30 seconds or so makes me think something isn’t working right here.
Help appreciated!