DreadsUK
06-06-2014, 02:27 PM
We now have a radio station for our site and i'm wondering which code to add and where.
If i add it to the main page. im concerned it will increase load time. Thought it best to create an article or a separate page. What would you suggest and where and which code do i add.
I've tried it using forum blocks but that means every page refresh stops the music and starts again when loaded
Javascript/HTML scripts
Song title (JS)
<script type="text/javascript" src="http://shoutcast.mixstream.net/js/song/uk30-free:16392">
You appear to have javascript turned off.
</script>
Number of listeners (JS)
<script type="text/javascript" src="http://shoutcast.mixstream.net/js/listeners/uk30-free:16392">You appear to have javascript turned off.
Online/Offline (JS)
<script type="text/javascript" src="http://shoutcast.mixstream.net/js/status/uk30-free:16392">You appear to have javascript turned off.
Online/Offline image (HTML)
<img src="http://shoutcast.mixstream.net/status/uk30-free:16392.gif" alt="Stream status" width="17" height="17" align="absmiddle">
Display Flash player (Pro Broadcasters Only)
<script>
// MixStream Flash Player, http://mixstreamflashplayer.net/
var flashvars = {};flashvars.serverHost = "s30.myradiostream.com:16392/;";flashvars.getStats = "1";flashvars.autoStart = "1";flashvars.textColour = "";flashvars.buttonColour = "";var params = {};params.bgcolor= "";params.wmode="transparent";
</script>
<script type="text/javascript" src="http://mixstreamflashplayer.net/v1.3.js"></script>
PHP scripts
PHP scripts are generally the most reliable and quickest way to get stats from your server. If these don't work then it's probably because either your webhost doesn't support PHP or they have a firewall blocking all outgoing connections, in which case you can either contact them or use the javascripts above.
Song title
<?php
$ip = "s30.myradiostream.com";
$port = "16392";
$fp = @fsockopen($ip,$port,$errno,$errstr,1);
if (!$fp) {
$title = "Connection timed out or the server is offline ";
} else {
fputs($fp, "GET /7.html HTTP/1.0\r\nUser-Agent: Mozilla\r\n\r\n");
while (!feof($fp)) {
$info = fgets($fp);
}
$info = str_replace('</body></html>', "", $info);
$split = explode(',', $info);
if (empty($split[6])) {
$title = "The current song is not available ";
} else {
$count = count($split);
$i = "6";
while($i<=$count) {
if ($i > 6) {
$title .= ", " . $split[$i];
} else {
$title .= $split[$i];
}
$i++;
}
}
}
$title = substr($title, 0, -2);
print $title;
?>
Number of listeners
<?php
$ip = "s30.myradiostream.com";
$port = "16392";
$fp = @fsockopen($ip,$port,$errno,$errstr,1);
if (!$fp) {
$listeners = "0;";
} else {
fputs($fp, "GET /7.html HTTP/1.0\r\nUser-Agent: Mozilla\r\n\r\n");
while (!feof($fp)) {
$info = fgets($fp);
}
$split = explode(',', $info);
if ($split[1] == "0") {
$listeners = "0";
} else {
$listeners = $split[0];
}
}
print $listeners;
?>
Online/Offline
<?php
// Change these to your online/offline messages //
$online = "Online"; // Displays when stream is online
$offline = "Offline"; // Displays when stream is offline
// don't edit below //
$ip = "s30.myradiostream.com";
$port = "16392";
$fp = @fsockopen($ip,$port,$errno,$errstr,1);
if (!$fp) {
$status = $offline;
} else {
fputs($fp, "GET /7.html HTTP/1.0\r\nUser-Agent: Mozilla\r\n\r\n");
while (!feof($fp)) {
$info = fgets($fp);
}
$split = explode(',', $info);
if ($split[1] == "0") {
$status = $offline;
} else {
$status = $online;
}
}
print $status;
?>
If i add it to the main page. im concerned it will increase load time. Thought it best to create an article or a separate page. What would you suggest and where and which code do i add.
I've tried it using forum blocks but that means every page refresh stops the music and starts again when loaded
Javascript/HTML scripts
Song title (JS)
<script type="text/javascript" src="http://shoutcast.mixstream.net/js/song/uk30-free:16392">
You appear to have javascript turned off.
</script>
Number of listeners (JS)
<script type="text/javascript" src="http://shoutcast.mixstream.net/js/listeners/uk30-free:16392">You appear to have javascript turned off.
Online/Offline (JS)
<script type="text/javascript" src="http://shoutcast.mixstream.net/js/status/uk30-free:16392">You appear to have javascript turned off.
Online/Offline image (HTML)
<img src="http://shoutcast.mixstream.net/status/uk30-free:16392.gif" alt="Stream status" width="17" height="17" align="absmiddle">
Display Flash player (Pro Broadcasters Only)
<script>
// MixStream Flash Player, http://mixstreamflashplayer.net/
var flashvars = {};flashvars.serverHost = "s30.myradiostream.com:16392/;";flashvars.getStats = "1";flashvars.autoStart = "1";flashvars.textColour = "";flashvars.buttonColour = "";var params = {};params.bgcolor= "";params.wmode="transparent";
</script>
<script type="text/javascript" src="http://mixstreamflashplayer.net/v1.3.js"></script>
PHP scripts
PHP scripts are generally the most reliable and quickest way to get stats from your server. If these don't work then it's probably because either your webhost doesn't support PHP or they have a firewall blocking all outgoing connections, in which case you can either contact them or use the javascripts above.
Song title
<?php
$ip = "s30.myradiostream.com";
$port = "16392";
$fp = @fsockopen($ip,$port,$errno,$errstr,1);
if (!$fp) {
$title = "Connection timed out or the server is offline ";
} else {
fputs($fp, "GET /7.html HTTP/1.0\r\nUser-Agent: Mozilla\r\n\r\n");
while (!feof($fp)) {
$info = fgets($fp);
}
$info = str_replace('</body></html>', "", $info);
$split = explode(',', $info);
if (empty($split[6])) {
$title = "The current song is not available ";
} else {
$count = count($split);
$i = "6";
while($i<=$count) {
if ($i > 6) {
$title .= ", " . $split[$i];
} else {
$title .= $split[$i];
}
$i++;
}
}
}
$title = substr($title, 0, -2);
print $title;
?>
Number of listeners
<?php
$ip = "s30.myradiostream.com";
$port = "16392";
$fp = @fsockopen($ip,$port,$errno,$errstr,1);
if (!$fp) {
$listeners = "0;";
} else {
fputs($fp, "GET /7.html HTTP/1.0\r\nUser-Agent: Mozilla\r\n\r\n");
while (!feof($fp)) {
$info = fgets($fp);
}
$split = explode(',', $info);
if ($split[1] == "0") {
$listeners = "0";
} else {
$listeners = $split[0];
}
}
print $listeners;
?>
Online/Offline
<?php
// Change these to your online/offline messages //
$online = "Online"; // Displays when stream is online
$offline = "Offline"; // Displays when stream is offline
// don't edit below //
$ip = "s30.myradiostream.com";
$port = "16392";
$fp = @fsockopen($ip,$port,$errno,$errstr,1);
if (!$fp) {
$status = $offline;
} else {
fputs($fp, "GET /7.html HTTP/1.0\r\nUser-Agent: Mozilla\r\n\r\n");
while (!feof($fp)) {
$info = fgets($fp);
}
$split = explode(',', $info);
if ($split[1] == "0") {
$status = $offline;
} else {
$status = $online;
}
}
print $status;
?>