function getCurrentTrack() {
$.get('/player/readerPlayer.php', function (data) {
$tracks = $(data).find('track');
$tracks.each(function (){
$this = $(this);
var title = $this.find('title').text();
var listenersn = $this.find('listeners').text();
$('.now_playing a').html(title).attr('href', url);
$('.listeners span').html(listenersn);
setTimeout(getCurrentTrack, 65000);
});
}, 'xml');
};
Where does url come from..? Presumably you need to extract it from location.
Code:
function getCurrentTrack() {
$.get('/player/readerPlayer.php', function (data) {
$tracks = $(data).find('track');
$tracks.each(function (){
$this = $(this);
var title = $this.find('title').text();
var listenersn = $this.find('listeners').text();
var locn = $this.find('location').text();
$('.now_playing a').html(title).attr('href', locn);
$('.listeners span').html(listenersn);
setTimeout(getCurrentTrack, 65000);
});
}, 'xml');
};
But you need to escape the ampersand & and other characters in the XML as it is not valid otherwise:
Quote:
& &
' '
" "
< <
> >
__________________
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
Validate your HTML and CSS
Last edited by AndrewGSW; 12-21-2012 at 11:34 AM..
<?xml version="1.0" encoding="UTF-8"?><tracks><track>
<title>Aly & Fila - Aly & Fila - Future Sound Of Egypt 259</title>
<listeners>3</listeners>
<location>http://94.23.250.14:8000/live</location>
</track></tracks>
__________________
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
Validate your HTML and CSS
function getCurrentTrack() {
$.get('/player/readerPlayer.php', function (data) {
$tracks = $(data).find('track');
$tracks.each(function (){
$this = $(this);
var title = $this.find('title').text();
var listenersn = $this.find('listeners').text();
$('.now_playing a').html(title).attr('href', url);
$('.listeners span').html(listenersn);
setTimeout(getCurrentTrack, 65000);
});
}, 'xml');
};
Where does url come from..? Presumably you need to extract it from location.
Code:
function getCurrentTrack() {
$.get('/player/readerPlayer.php', function (data) {
$tracks = $(data).find('track');
$tracks.each(function (){
$this = $(this);
var title = $this.find('title').text();
var listenersn = $this.find('listeners').text();
var locn = $this.find('location').text();
$('.now_playing a').html(title).attr('href', locn);
$('.listeners span').html(listenersn);
setTimeout(getCurrentTrack, 65000);
});
}, 'xml');
};
But you need to escape the ampersand & and other characters in the XML as it is not valid otherwise:
It seems your code is working! though your right...every time the xspf generates the amp sign (&) the php fails to read. i posted the start of the remote xspf file (i need admins approval for posts for some reason and it takes forever so sorry for posting 2 replies)
although it is preferable that the source-XML is corrected.
__________________
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
Validate your HTML and CSS
Last edited by AndrewGSW; 12-21-2012 at 02:35 PM..
I don't know if this can be done in PHP; probably, but not simply. You would probably need to read the file as a text file, replace the & and other characters, re-store this new file on the server, then re-parse it as XML.
But the original XML file is malformed and should be corrected.
__________________
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
Validate your HTML and CSS
Last edited by AndrewGSW; 12-21-2012 at 02:40 PM..
But the original XML file is malformed and should be corrected.
I would go for that yes.
But the question is, how? hehe how do i go about fixing these issues..i have very limited understanding of XML parsing, so what should i look for if the data is auto generated by whats actually playing on the server?
btw the xspf i attached above is the actual XML file in the production server. (xspf.xml)
My experience of XML and related technologies is limited, but cannot you or someone else modify the xspf file to include the encode() function I suggested?
Added: I'm guessing it's like this:
the php is requested;
this php page loads and executes the xspf file, which is an XML-Transform file - which transforms an XML document from one XML-structure to another;
the transform get's its source data from either an XML-document or a database - I suspect, a database;
this all executes on the server before returning the (final) XML data.
So there is no source to modify, unless the database-data itself can be modified. So, as I see it, modifying the xspf.xml is the solution.
But I may be completely wrong .
__________________
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
Validate your HTML and CSS
Last edited by AndrewGSW; 12-21-2012 at 06:03 PM..