I'm having trouble figuring out how to get this class to read the information it needs from a directory other than the one it's located. The class pulls the ID3 information from MP3 files and works great as long as the files are in the same directory. How would I force it to look at files in a different one. Say in "podcasts/"?
Code:
class CMP3File {
//properties
var $title;
var $artist;
var $album;
var $year;
var $comment;
var $genre;
function getid3($file)
{ // read the ID3 or ID3v2 tag from an MP3 file
if (file_exists($file))
{ //after verifying the file exists,
$id_start = filesize($file) - 128;
$fp = fopen($file, "r");
fseek($fp, $id_start);
$tag = fread($fp,3);
if ($tag == "TAG")
{
$this->title = stripJunk(trim(fread($fp, 30)));
$this->artist = stripJunk(trim(fread($fp, 30)));
$this->album = stripJunk(trim(fread($fp, 30)));
$this->year = stripJunk(trim(fread($fp, 4)));
$this->comment = stripJunk(trim(fread($fp, 30)));
$this->genre = stripJunk(trim(fread($fp, 1)));
fclose($fp);
return true;
}
else
{ // No ID3 tag
fclose($fp);
return false;
}
} else //the file doesn't exist
return false;
}
Well I go through that class in a loop until all the files in the directory are read so I don't want to specify the exact file. Just the directory. Does that make sense? I'm fairly new at this so if I'm not providing you with enough info, I appologize
The simplest anwser would be to change
$mp3file->getid3 ($filename);
into
$mp3file->getid3 ('podcasts/' . $filename);
You have to add the path to the file.
BTW there was an error in my last post.
__________________
I'm not sure if this was any help, but I hope it didn't make you stupider.
Experience is something you get just after you really need it. PHP Installation Guide Feedback welcome.