Icecast Streaming Media Server Forum Index Icecast Streaming Media Server
Icecast is a Xiph Foundation Project
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

PHP & AJAX to get song title

 
Post new topic   Reply to topic    Icecast Streaming Media Server Forum Index -> Icecast Server
View previous topic :: View next topic  
Author Message
krazybob



Joined: 06 Oct 2008
Posts: 18

PostPosted: Mon Oct 06, 2008 6:21 pm    Post subject: PHP & AJAX to get song title Reply with quote

I have spent hours scouring the internet for a PHP and AJAX solution that will allow me to pull the song title for placement on a web page. I know how to update the song title Smile

Can anyone help?
Back to top
View user's profile Send private message
liteFun



Joined: 13 Jan 2006
Posts: 79

PostPosted: Mon Dec 15, 2008 8:09 pm    Post subject: Reply with quote

I have in between <head> and </head> this one:
Code:
<script type="text/JavaScript">

function getHTTPObject() {
         var xmlhttp;
         /*@cc_on
         @if (@_jscript_version >= 5)
         try {
                  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
                  try {
                           xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
                  } catch (E) {
                           xmlhttp = false;
                  }
         }
         @else
         xmlhttp = false;
         @end @*/
         if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
                  try {
                           xmlhttp = new XMLHttpRequest();
                  } catch (e) {
                           xmlhttp = false;
                  }
         }
         return xmlhttp;
}

var http = getHTTPObject();
var isBusy = false;

function getInfo(){
         var myRandom=parseInt(Math.random()*99999999); // cache buster
         if (isBusy) {
                  http.abort();
         }
         http.open('GET', 'np.html?rand=' + myRandom, true);
         isBusy = true;
         http.onreadystatechange = handleInfo;
         http.send(null);
}

function handleInfo(){
         if(http.readyState == 4){
                  document.getElementById('view_ajax').innerHTML = http.responseText;
                  isBusy = false;
         } else {
                  return;
         }
}


function go(){
         getInfo();
         window.setTimeout("go()", 20000);
}
</script>


And, then I have this:
Code:
<body onLoad="javascript:go()">


And in the html/php I have this:
Code:
<h3><b>Currently played:</b></h3>
 <div id="view_ajax">Please wait, gathering information...</div>
<font size="1">(automatically updated)</font>
Back to top
View user's profile Send private message
liteFun



Joined: 13 Jan 2006
Posts: 79

PostPosted: Mon Dec 15, 2008 8:14 pm    Post subject: Reply with quote

^I had that previously PM'd to krazybob.

Oh and of course, you have to transfer np.html to same directory where you have that web page (or modify np.html path).
That can do with Winamp and Now-Playing plugin by M. Nevala (found on winamp.com, if you use Winamp).
Back to top
View user's profile Send private message
Cleiton



Joined: 17 Apr 2009
Posts: 1

PostPosted: Fri Apr 17, 2009 4:32 pm    Post subject: Reply with quote

Where I can get np.html?? Confused
Back to top
View user's profile Send private message
liteFun



Joined: 13 Jan 2006
Posts: 79

PostPosted: Tue Jun 02, 2009 9:45 pm    Post subject: Reply with quote

Read the message above Wink
In my case, np.html is just generated with Winamp plugin.
Some players can do text/html-file of what they play, or you could run php-script to extract currently playing song from Icecast stats and save it as (preformatted html) file.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Icecast Streaming Media Server Forum Index -> Icecast Server All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2002 phpBB Group
subRebel style by ktauber