| px | top | add code | search | signup | login | help |
# getid3 - get id3 v1.1 tag information of an .mp3 file
# in: filename
# out: array(songname, artis, album, year, comment, genre) else false
function getid3 ($file)
{
if (file_exists($file))
{
/* this is done because filesize($fp) gave me false - lost my patiance - ;-( */
$fp=fopen($file,"a+"); $id_start=ftell($fp)-128; fclose($fp);
/* "real" code starts here */
$fp=fopen($file,"r");
fseek($fp,$id_start);
$tag=fread($fp,3);
if ($tag=="TAG")
{
$id3songname=fread($fp,30);
$id3artist=fread($fp,30);
$id3album=fread($fp,30);
$id3year=fread($fp,4);
$id3comment=fread($fp,30);
$id3genre=fread($fp,1);
$idtag=array(0=>$id3songname,1=>$id3artist,2=>$id3album,3=>$id3year,4=>$id3comment,5=>$id3genre);
return $idtag;
} else return false;
fclose($fp);
} else return false;
}
Comments or questions?
PX is running PHP 5.2.11
Thanks to Miranda Productions for hosting and bandwidth.
Use of any code from PX is at your own risk.