Scripts
SHOUTrds is a streamrds software that just updates the songtitle of your SHOUTcast server, so putting it on your webiste is quite easy!
Here is how it works:
RDS provided by HotTracksFM!
Loading, please wait. . .
|
Here is how it works
The first thing you need is a JavaScript file which contains the code to "Update" the stream title every ×× seconds.The script looks like this:
Filename: rds.js
var xmlHttp function showrds(str) { xmlHttp=GetXmlHttpObject() if (xmlHttp==null) { alert ("Browser does not support HTTP Request") return } var url="rds.php" url=url+"?q="+str url=url+"&sid="+Math.random() xmlHttp.onreadystatechange=stateChanged xmlHttp.open("GET",url,true) xmlHttp.send(null) setTimeout("showrds()", 5000); } function stateChanged() { if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { document.getElementById("txtHint").innerHTML=xmlHttp.responseText } }function GetXmlHttpObject() { var xmlHttp=null; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { //Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; } |
So when we have the rds.js file, we can write a peace of HTML code to execute the function "showrds" in the script file.
Include the following html code in the >head> part of your website (somewhere else is also possible).
<script> src="rds.js"></script> <script> showrds(); </script> |
As you can see in the rds.js, it calls a file called "rds.php".
This file reads the SHOUTcast 7.html to retrieve song information, current stream status, current listeners, max listeners etc.
The file may look like this:
<?php error_reporting(0); if(!$fp = @fsockopen("host", "port", &$errno, &$errstr, 3)) { // Connection failed echo "Server is currently down!"; } else { //Get 7.html fputs($fp,"GET /7.html HTTP/1.0\r\nUser-Agent: XML Getter (Mozilla Compatible)\r\n\r\n"); while(!feof($fp)) { //The var $page gets the result of the 7.html. $page = fgets($fp, 1000); } //Close the connection because we no longer need it. fclose($fp); //Remove stuff we don't need ( html tags) $page = ereg_replace(".*<body>", "", $page); $page = ereg_replace("</body>.*", ",", $page); //Rip data we need. $shoutcast = explode(",",$page); //Convert pageinfo to variable //Je kunt commanten wat je nie nodig hebt... hoeft niet... $luisteraars = $shoutcast[0]; //Number of listeners $streaming = $shoutcast[1]; //streamstatus 1 = streaming 0 = not streaming $piek = $shoutcast[2]; //Peak $max = $shoutcast[3]; //Max. listeners $unieke = $shoutcast[4]; //Unique listeners $bitrate = $shoutcast[5]; //Bitrate $song = $shoutcast[6]; //Current song //Is streaming? display something if(isset($streaming)) { if($streaming == "1") { Echo $song; // output "$song" (the songtitle) this output will be shown on the RDS container. } } //There is no stream if(isset($streaming)) { if($streaming == "0") { echo "Server is currently down!"; } } } ?> |
So now we've got all the scripts ready, but we want to display the RDS somewhere on the page.
Use the following code "somewhere" on your HTML page.
<div id="txtHint"><b>Loading, please wait. . .</b></div> |