Old 11th July 2017, 21:34   #1
Junior Member
Join Date: Sep 2015
Posts: 9
Really Simple AJAX now playing script

Super easy now playing script, contains 2 files and updates the current song every 10 seconds.

If you are using php simply include demo.php wherever you want the song to be displayed.

<?php include 'demo.php'; ?>


//error_reporting(E_ERROR | E_WARNING | E_PARSE);


<html><script type="text/javascript" src="http://ajax.googleapis.com/ajax/
<script type="text/javascript">
var auto_refresh = setInterval(
function ()
}, 10000); // refresh every 10000 milliseconds (10 seconds)
<div id="load_songs"><center><small> Loading Stream Please Wait.....</small></center></div>



$sc_url_ip = "6x.3x.18x.14x"; // <= CHANGE THIS TO YOUR IP
//ex: 6x.3x.18x.14x

$sc_url_port = "8000"; // <= CHANGE THIS IF NEEDED

function getNowPlaying($sc_url_ip,$sc_url_port)

$open = fsockopen($sc_url_ip,$sc_url_port,$errno,$errstr,'.5');
if ($open) {
fputs($open,"GET /7.html HTTP/1.1\nUser-Agent:Mozilla\n\n");
$read = fread($open,200);
$text = explode(",",$read);
if($text[6] == '' || $text[6] == '</body></html>'){ $msg = ' live stream '; } else { $msg = $text[6]; }
$text = $msg;
} else { return false; }

return $text;


//get the song now playing

$current_song = getNowPlaying($sc_url_ip,$sc_url_port);

//print $current_song;

//print $current_song;
$singinfo = explode(" - ",$current_song);

$artist = urlencode($singinfo[0]);
$album = urlencode(strip_tags($singinfo[1]));


ricktee76 is offline   Reply With Quote
Old 14th July 2017, 08:02   #2
Major Dude
dopelabs's Avatar
Join Date: Oct 2006
Location: Silicon Valley
Posts: 539
Send a message via AIM to dopelabs
I wouldn't call this an 'AJAX' script... I would call this a PHP script. since its PHP thats actually doing all the work here. this also requires the web host to support sockets in their PHP configuration, most shared hosting providers don't. the only thing you are using Ajax for is calling the php script and displaying it within a div.... AJAX will also not load cross domain or cross port, you need to use something like jsonp.

if you have a V2 DNAS

<!DOCTYPE html>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
url : "http://IP:PORT/statistics?json=1",
dataType: 'JSONP',
type : "GET",

dopelabs is offline   Reply With Quote
Go Back   Winamp & Shoutcast Forums > Shoutcast > Shoutcast Discussions

now playing, php

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump