Hey there!
I am designing a website but got stuck on trying to do this.
The idea around is is that we display a stream on top of our page. However to have it streaming most of the time we like to be able to check if streamer is on, and if not move on to next and see if that person is online, and so on until it reached the end or an online streamer. When someone is online i would like to echo code.
This is the code i have so far
<?php
function reloadFrame() {
for (var i=1;i<=14;i++){
var nm = 'frame' + i;
var e = document.getElementById(nm).attributes[4].nodeValue;
e = e.split("/");
e = e[e.length-2];
var ur = 'https://api.twitch.tv/kraken/streams/CelPlays' + e;
$.ajax({
url: ur,
dataType: 'jsonp',
type: 'get',
success: function(data) {
if(data.stream === null) {
//here i would like to add in, that if celplays is online to search if CohhCarnage is online(or someone else) And so on for a couple until there is one online. If online then to display code provided under this frame.
//And if next is online the also display embed viewer. and so on.
else{
echo("")//if is on then just display code for the embed viewer.
}
}
}
}
}
}
?>
Code to echo ->
<iframe src="http://www.twitch.tv/INSERTSTREAMERNAME/embed" frameborder="0" scrolling="no" height="210" width="400" style=" -webkit-box-shadow: 0px 0px 5px 5px rgba(0, 0, 0, 0.75); -moz-box-shadow:0px 0px 5px 5px rgba(0, 0, 0, 0.75); box-shadow:0px 0px 5px 5px rgba(0, 0, 0, 0.75);"></iframe>
Is there any possiblty to do this? Or am i going the wrong way with the code?
Greets!