Results 1 to 3 of 3
  1. #1

    Title
    Junior Broadcaster
    Join Date
    Nov 2014
    Posts
    28
    Rep Power
    6

    Simple script listener/current track php/ajax

    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

    Code:
    <?php
    $icecast_url='http://stream_url.com:8000';
    $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);
    $j=count($matches[0]);
    for ($i=0;$i<$j; $i++) {
    $point_name=$matches[1][$i];
    $pount_m3u=$icecast_url.$matches[2][$i];
    $point_listners_count=$matches[3][$i];
    $point_current_song=$matches[4][$i];
    //
    
    echo 'Listeners: '.$point_listners_count.' ';
    echo 'Playing: '. $point_current_song.'';
    }
    ?>
    The AJAX script I got here http://www.brightcherry.co.uk/scribb...ery-x-seconds/

    Code:
    <html>
    <head>
    <!-- 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>
    <script>
     $(document).ready(function() {
          $("#responsecontainer").load("stream.php");
       var refreshId = setInterval(function() {
          $("#responsecontainer").load('stream.php?randval='+ Math.random());
       }, 9000);
       $.ajaxSetup({ cache: false });
    });
    </script>
    </head>
    <body></body>
    Last edited by deaddred; 11-25-2014 at 11:21 PM. Reason: more info

  2. #2

    Title
    Junior Broadcaster
    Join Date
    Nov 2014
    Posts
    28
    Rep Power
    6
    You can see it working here http://futureassassin.com/

  3. #3

    Title
    Junior Member
    Join Date
    Nov 2009
    Posts
    6
    Rep Power
    0
    Hello,

    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.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •