I am trying to use the XSPF music player from
http://musicplayer.sourceforge.net/ , it works fine when i create a standard xspf playlist in the format prescribed at
http://www.xspf.org/ . I have a sample located here
www.wirralweb.me.uk/demo.xspf which contains:
- Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<playlist version="0" xmlns="http://xspf.org/ns/0/">
<trackList>
<track>
<location>http://www.wirralweb.me.uk/mp3s/boag2.mp3</location>
<creator>dfsdfsdfsdf</creator>
<album>dfsf</album>
<title>fsdfsdf</title>
<annotation>poo</annotation>
</track>
</trackList>
</playlist>
However i want this list to be generated from a directory /mp3s using the getid3 classes.
I have the
PHP script at
www.wirralweb.me.uk/demo.php and it contains:
- Code: Select all
<?php
header("Content type: application/xspf+xml");
echo '<?xml version="1.0" encoding="UTF-8"?>
<playlist version="0" xmlns="http://xspf.org/ns/0/">
<trackList>';
include("funcs.php");
createplaylist();
echo '
</trackList>
</playlist>';
?>
and... funcs.
php contains:
- Code: Select all
<?php
function createplaylist() {
require_once('getid3/getid3.php');
// Initialize getID3 engine
$getID3 = new getID3;
$DirectoryToScan = $_SERVER['DOCUMENT_ROOT']."/mp3s"; // change to whatever directory you want to scan
$dir = opendir($DirectoryToScan);
while (($file = readdir($dir)) !== false) {
$FullFileName = realpath($DirectoryToScan.'/'.$file);
if (is_file($FullFileName)) {
set_time_limit(30);
$ThisFileInfo = $getID3->analyze($FullFileName);
getid3_lib::CopyTagsToComments($ThisFileInfo);
// output desired information in whatever format you want
$location = "http://www.wirralweb.me.uk/".$file;
$title = $ThisFileInfo['comments_html']['title'][0];
$artist = $ThisFileInfo['comments_html']['artist'][0];
$album = $ThisFileInfo['comments_html']['album'][0];
echo "
<track>
<location>$location</location>
<creator>$artist</creator>
<album>$album</album>
<title>$title</title>
<annotation>poo</annotation>
</track>";
}
}
}
?>
it generates the EXACT same code as demo.xspf however the player does not use the data, any comments on my code or reasons why you think this may not be working would be much appreciated.
music players located at
www.wirralweb.me.uk/music.php -
php script
and
www.wirralweb.me.uk/music1.php - static xspf file
many thanks in advance