| View previous topic :: View next topic |
| Author |
Message |
krazybob
Joined: 06 Oct 2008 Posts: 18
|
Posted: Mon Oct 06, 2008 6:21 pm Post subject: PHP & AJAX to get song title |
|
|
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
Can anyone help? |
|
| Back to top |
|
 |
liteFun
Joined: 13 Jan 2006 Posts: 79
|
Posted: Mon Dec 15, 2008 8:09 pm Post subject: |
|
|
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 |
|
 |
liteFun
Joined: 13 Jan 2006 Posts: 79
|
Posted: Mon Dec 15, 2008 8:14 pm Post subject: |
|
|
^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 |
|
 |
Cleiton
Joined: 17 Apr 2009 Posts: 1
|
Posted: Fri Apr 17, 2009 4:32 pm Post subject: |
|
|
Where I can get np.html??  |
|
| Back to top |
|
 |
liteFun
Joined: 13 Jan 2006 Posts: 79
|
Posted: Tue Jun 02, 2009 9:45 pm Post subject: |
|
|
Read the message above
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 |
|
 |
|