Skip to content

Instantly share code, notes, and snippets.

@CBenni
Created June 23, 2015 17:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CBenni/f5d859c95b8490809e86 to your computer and use it in GitHub Desktop.
Save CBenni/f5d859c95b8490809e86 to your computer and use it in GitHub Desktop.
bdYgwY
Select a channel: <input type="text" id="channelSel" value="cbenni"/>
<div id="stream"><iframe src="http://www.twitch.tv/smites/embed" frameborder="0" scrolling="no" height="378" width="620"></iframe></div>
$(function(){
setInterval(checkStreamOnline,30000);
checkStreamOnline();
$("#channelSel").change(checkStreamOnline);
});
function checkStreamOnline()
{
$.ajax({url:"https://api.twitch.tv/kraken/streams/",data:{"channel":$("#channelSel").val(),"callback":"streamsCallback"},crossDomain: true,dataType: 'jsonp'});
}
function streamsCallback(data)
{
if(data.streams.length>0)
{
$("#stream").show("slow");
}
else
{
$("#stream").hide("slow");
}
}
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment