1

I want extract audio stream track details from tracklist.xspf file stored on remote server and print output on web page as scrolling text inside div, so PHP script should print current track info. I want get details from tags 'title', 'annotation' (only Stream Title:) and 'info'. For last 'info' tag, I want to make it can be turned off and instead I will scroll my custom (preset) text. The track info on page need be periodically refreshed to get current track details.

the tracklist.xspf file content:

<?xml version="1.0" encoding="UTF-8"?>
<playlist xmlns="http://xspf.org/ns/0/" version="1">
  <title/>
  <creator/>
  <trackList>
    <track>
      <location>http://geodesic1.streams.audioaddict.com:80/di_chillout3</location>
      <title>Ulrich Schnauss - Between Us And Them</title>
      <annotation>Stream Title: Chillout - ambient psy chillout.

Content Type:audio/mpeg
Current Listeners: 0
Peak Listeners: 0
Stream Genre: Electronic Chillout Ambient</annotation>
      <info>http://www.di.fm</info>
    </track>
  </trackList>
</playlist>

Can someone show how to accomplish this task with php script? The example solution would be greatly appreciated.

fxgreen
  • 424
  • 1
  • 10
  • 24
  • Use [DOMDocument](http://php.net/manual/en/class.domdocument.php) – Nadh May 03 '12 at 14:23
  • something like this? `$data = new DOMDocument(); $data->load('http://full/path/to/tracklist.xspf'); if($data->load("http://full/path/to/tracklist.xspf")) { foreach ($data->getElementsByTagName('entry') as $track) { $title = $track->getElementsByTagName('title')->item(0)->nodeValue; $annotation = $track->getElementsByTagNameNS('annotation')->item(0)->nodeValue; $info = $track->getElementsByTagNameNS('info')->item(0)->nodeValue; print($track); } }` – fxgreen May 03 '12 at 21:01
  • That's along the right lines. While looping through the tags, you can use `removeNode()` to remove unwanted tags. – Nadh May 04 '12 at 05:25
  • not working the way I need it to. I searched php and msdn documentation but couldn't find close example for my case. I'm not a PHP expert at all. Just wanted that script extract the required details and scroll it inside div in one row, similar to desktop mp3 players like winamp. – fxgreen May 04 '12 at 14:17

0 Answers0