From what I've been able to get from the embed page, this working example renders correctly. I've annotated the Javascript so it "should" be easy to follow.
HTML Code:
<!DOCTYPE html>
<html>
<head id="pageHead">
<!-- Page Title-->
<title>Caster.FM API Hack</title>
<!-- Meta Block -->
<meta content="text/html; charset=iso-8859-1" http-equiv="content-type" />
<meta content="Caster.FM API Hack" name="description" />
<meta content="caster.fm, api, hack" name="keywords" />
<meta content="all,index,follow" name="robots" />
<meta content="noodp" name="msnbot" />
<meta content="global" name="distribution" />
<!-- JavaScript Scripts-->
<script type="text/javascript">
//<![CDATA[
/*
* Checks whether the radio is online and modifies the page respectively.
*/
function isRadioOnline() {
/*
* Depending on how the Radio Player is embedded onto the page,
* the injected <object> will have different ids.
*
* Embedded as Flash = 'player_api'
* Embedded as MediaPlayer = 'MediaPlayer1'
* Embedded as HTML5 = 'jp_container_1'
*/
var EmbeddedAs = {
Flash: 'player_api',
MediaPlayer: 'MediaPlayer1',
HTML5: 'jp_container_1'
};
/*
* Is the radio online?
*
* If the injected element exists on the page then the radio
* is online, if it doesn't, the code below is run.
*
* NOTE:
*
* Check to see how your script embeds the player and change
* the if statement to match your own settings.
*
* @see EmbeddedAs namespace
*/
if (!document.getElementById(EmbeddedAs.Flash)) { // Player Offline
/*
* Locate relevent DIVs on the page.
*/
var divChatBox = document.getElementById('chatbox');
var divRadio = document.getElementById('radio');
/*
* Clean divRadio and add custom message.
*/
divRadio.innerHTML = '<p>Sorry, we are not currently broadcasting, please try again soon.</p>';
/*
* Clean divChatBox.
*
* Choose one of two methods:
*/
//divChatBox.innerHTML = ''; // Removes all HTML from within the DIV.
divChatBox.style.display = 'none'; // Makes the DIV invisible.
} else { // Radio is online.
/*
* Optional area to write any scripts to run when the player is online.
*/
}
}
/*
* Launch isRadioOnline() function when the page is loaded.
*/
window.addEventListener('load', isRadioOnline, false);
//]]>
</script>
</head>
<body>
<div id="page">
<div id="chatbox">
<object width="550px" height="550px" data="http://info.info-info-info-info-info.info/list.swf?r=295021&l=www"
type="application/x-shockwave-flash">
<param value="http://info.info-info-info-info-info.info/list.swf?r=295021&l=www"
name="movie" />
<param value="#ffffff" name="bgcolor" />
<param value="always" name="allowscriptaccess" />
<embed width="550" height="550" src="http://info.info-info-info-info-info.info/list.swf?r=295021&l=www"
type="application/x-shockwave-flash" />
<video width="550px" height="550px">
</video>
</object>
</div>
<div id="radio">
<script src="http://www.caster.fm/embed.php?uid=30978" type="text/javascript" />
</div>
</div>
</body>
</html>
Unfortunately, I haven't been able to get the UID of a currently online radio station, so I haven't had a chance to test the code, other than to switch the operator on the if statement to mimic a true result. This may be a lot easier if it also injects the surrounding "player" DIV that the standard subdomain.caster.fm uses. That way, you wouldn't need the EmbeddedAs part.
Caster.FM currently has an API in the pipeline but it hasn't been made public yet. Once the API is out, it should be alot easier to do this stuff.
There is another method, you could use a ServerSide language like PHP or ASP.NET to grab the information with a Shoutcast/Icecast API.
ASP.NET: http://shoutcastnet.codeplex.com/
PHP: http://devshed.excudo.net/scripts/ph...internet+radio
Bookmarks