List files with certain id3 tags
Posted: Sun Aug 06, 2006 10:22 pm
I am wanting to list mp3's in a directory, but ONLY if the artist is System of a Down, it reads the files' id3 tags, but I obviously messed up somewhere., since It displays a blank page.
And, I have several songs for that artist, and they are in the same directory and I am sure the songs have that artist in their id3 tags. I have a different script that will display the id3 tags of a specific file to verify it.
Code: Select all
<?php
$path = "/homepages/21/d155481990/htdocs/server";
$dir_handle = @opendir($path) or die("Unable to open $path");
while ($file = readdir($dir_handle))
{
if($file!="." && $file!=".." && $file!="songlist.php" && $file!="song.php" && $file!="music.html" && $file!="songdevlist.php" && $file!=null)
$mp3 = $file; //MP3 file to be read
$filesize = filesize($mp3);
$file = fopen($mp3, "r");
fseek($file, -128, SEEK_END);
$tag = fread($file, 3);
if($tag == "TAG")
{
$data["artist"] = trim(fread($file, 30));
}
else
die("");
fclose($file);
strtolower($mp3);
while(list($key, $value) = each($data))
{
if ($data["artist"] == 'system of a down')
{ print("$key: $value<br>\r\n"); }
}
}
//closing the directory
closedir($dir_handle);
?>And, I have several songs for that artist, and they are in the same directory and I am sure the songs have that artist in their id3 tags. I have a different script that will display the id3 tags of a specific file to verify it.