uStream.tv Status (Java Script)
Posted by DremationAug 4
I was called upon today by a new friend to write a small script to detect the streaming status of a uStream.tv channel. I thought I”d share the script with everyone.
****OK OK, My CodeBox plugin is not working, please be patient.****
<!--Place this code where you want the status to appear. -->
<font color='red'><span id="status">status</span></font>
<!--Place this code anywhere in the page. -->
<script type="text/javascript">
function set_status(status)
{
if (status == "offline")
{ <!-- replace the img html with any html that you need -->
document.getElementById("status").innerHTML = "<img src='http://lifeofajackass.com/offline.png'/>";
}
else if (status == "live")
{ <!-- replace the img html with any html that you need -->
document.getElementById("status").innerHTML = "<img src='http://lifeofajackass.com/online.png'/>";
}
else
{ <!-- Let's do this just in case the service is down or something. You could show an error image as well -->
document.getElementById("status").innerHTML = "Error getting stream status!";
}
}
</script>
<!--Make sure to replace the channel name and API key. -->
<script type="text/javascript" src="http://api.ustream.tv/json/channel/CHANNELNAME/getValueOf/status?key=YOURAPIKEY&callback=set_status">
</script>
Popularity: unranked [?]
