View Full Version : Simple script listener/current track php/ajax

11-25-2014, 11:06 PM
Not sure how efficient this script is but atm while I'm still gathering software for my station I got these two scripts to work together to display the listener count and current track and refresh the info automatically every 5 or so seconds.

The php script. Put this into stream.php file

$output = file_get_contents($icecast_url);
$search='#<div class="newscontent">.*?Point /(.*?)<.*?href="(.*?)">M3U<.*?Listeners.*?class="streamdata">(.*?)<.*?Song:.*?class="streamdata">(.*?)<.*?</div>#si';
preg_match_all($search, $output, $matches);
for ($i=0;$i<$j; $i++) {

echo 'Listeners: '.$point_listners_count.' ';
echo 'Playing: '. $point_current_song.'';

The AJAX script I got here http://www.brightcherry.co.uk/scribbles/jquery-auto-refresh-div-every-x-seconds/

<!-- For ease i'm just using a JQuery version hosted by JQuery- you can download any version and link to it locally -->
<script src="http://code.jquery.com/jquery-latest.js"></script>
$(document).ready(function() {
var refreshId = setInterval(function() {
$("#responsecontainer").load('stream.php?randval='+ Math.random());
}, 9000);
$.ajaxSetup({ cache: false });

11-25-2014, 11:21 PM
You can see it working here http://futureassassin.com/

01-26-2015, 06:57 AM

I am wanting an icecast Now Playing script on my website. I am stuck on how to install this one onto my website. Can you please explain it. It keeps coming up with an error on line 3.