I generate a playlist with following script:
<?php
$dir = './music';
$url = 'music';
header('Content-type: text/xml');
echo '<?xml version="1.0" encoding="utf-8"?>' . "\n";
echo '<playlist>';
if (is_dir($dir)) {
$dp = opendir($dir);
while (false !== ($file = readdir($dp))){
if ('mp3'==strtolower(substr($file, -3))) {
printf('<sound src="%s/%s" stream="true" soundbuffer="8">%s</sound>', $url, $file, str_replace('_', ' ', substr($file, 0, -4)));
echo "\n";
}
}
closedir($dp);
}
echo '</playlist>';
How do I get the artist and length from each mp3 file?
Thanks in advance
You need to parse the file and extract the data. It can’t give you any more info as you haven’t indicated the ID3 version (and there are several). Wikipedia has information on the diffrences between ID3v1 and v2
A better option would be to use a library, something like ID3 or getID3