i need a script that list the mp3 files in a dir, and at this list, show the id3 os the mp3 files, exemple:
---
braveheart-children.mp3
song: Children
artist: Hiding Place (ep)
album: Braveheart
year: 2001
manu_chao-proxima_estacion_esperanza.mp3
song; Proxima Estación Esperanza
Artist Manu Chao
Album Proxma Estación Esperanza
Year: 2000
---
i have this code, but it don't function. It shows only the 1st registry. If you want to help, you can edit this code, or suggest me another. Thanks.
Code: Select all
<?php
unset($G['file_list'], $G['pfile_list'], $G['filename']);
//-------------------------------
// Build list of uploaded files
//-------------------------------
$diretorio = "/var/www/derock/derock/mp3/";
$dh = opendir($diretorio);
if ($dh == FALSE) {
echo "ERROR opening file"; exit;
}
$x = 0;
while (FALSE !== ($file = readdir($dh))) {
if ("." == $file OR ".." == $file) {
continue; // Skip non files
}
//echo $file."<br/>";
$file_list[$x] = $file;
$x++;
}
// If we had no files in our list, display a screen error
if (0 == $x) {
echo "There are no files available for processing.";
} else {
// If we had some files in our list, sort them and echo the list
sort($file_list);
for ($i = 0; $i <= $x; $i++) {
$arquivos_array[] = "$file_list[$i]";
}
}
// lista o conteudo do array $arquivos_array
while(list($key, $value) = each($arquivos_array))
{
print("<BR><BR>$key: $value<BR>\r\n");
// informa o ID3.V1
$mp3 = $diretorio . $value;
$file = fopen("$mp3", "r");
fseek($file, -128, SEEK_END);
$tag = fread($file, 3);
if($tag == "TAG")
{
$data["song"] = trim(fread($file, 30));
$data["artist"] = trim(fread($file, 30));
$data["album"] = trim(fread($file, 30));
$data["year"] = trim(fread($file, 4));
$data["comment"] = trim(fread($file, 30));
}
else
die("Mp3 does not contain an ID3 tag!");
fclose($file);
while(list($key, $value) = each($data))
{
print("$key: $value<BR>\r\n");
}
}
?>