I use the following script:
<?PHP
include ("CMP3File.php"
$filename = "mp3/01.mp3";
$mp3file = new CMP3File;
$mp3file->getid3 ($filename);
echo ("Title: $mp3file->title<br>\n"
echo ("Artist: $mp3file->artist<br>\n"
echo ("Album: $mp3file->album<br>\n"
echo ("Year: $mp3file->year<br>\n"
echo ("Comment: $mp3file->comment<br>\n"
echo ("Genre: " . Ord($mp3file->genre) . "<br>\n"
?>
and CMP3File.php:
<?php
class CMP3File
{ // CMP3File declaration
//properties
var $title;
var $artist;
var $album;
var $year;
var $comment;
var $genre;
function getid3 ($file)
{ // read the ID3 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 = fread($fp, 30);
$this->artist = fread($fp, 30);
$this->album = fread($fp, 30);
$this->year = fread($fp, 4);
$this->comment = fread($fp, 30);
$this->genre = fread($fp, 1);
fclose($fp);
return true;
}
else
{ //there is no ID3 tag in the file
fclose($fp);
return false;
}
} else //the file doesn't exist
return false;
}
}
?>
Everything is right, but when displaying the genre, I get a number. Like this:
Title: We're At The Top Of The World
Artist: The Juliana Theory
Album: Emotion Is Dead
Year: 2000
Comment: Good Song!
Genre: 17
Each genre has a number. Rock = 17, Hip Hop = 125, etcetera.
What I need is: if the script puts out number 17, it has to display 'ROCK', and if it puts out 125, it has to display 'HIPHOP'.
Does anyone know how I can do all this? There's about 150 genre's so keeping the scriptsize to a minimum would be preferable.
<?PHP
include ("CMP3File.php"
$filename = "mp3/01.mp3";
$mp3file = new CMP3File;
$mp3file->getid3 ($filename);
echo ("Title: $mp3file->title<br>\n"
echo ("Artist: $mp3file->artist<br>\n"
echo ("Album: $mp3file->album<br>\n"
echo ("Year: $mp3file->year<br>\n"
echo ("Comment: $mp3file->comment<br>\n"
echo ("Genre: " . Ord($mp3file->genre) . "<br>\n"
?>
and CMP3File.php:
<?php
class CMP3File
{ // CMP3File declaration
//properties
var $title;
var $artist;
var $album;
var $year;
var $comment;
var $genre;
function getid3 ($file)
{ // read the ID3 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 = fread($fp, 30);
$this->artist = fread($fp, 30);
$this->album = fread($fp, 30);
$this->year = fread($fp, 4);
$this->comment = fread($fp, 30);
$this->genre = fread($fp, 1);
fclose($fp);
return true;
}
else
{ //there is no ID3 tag in the file
fclose($fp);
return false;
}
} else //the file doesn't exist
return false;
}
}
?>
Everything is right, but when displaying the genre, I get a number. Like this:
Title: We're At The Top Of The World
Artist: The Juliana Theory
Album: Emotion Is Dead
Year: 2000
Comment: Good Song!
Genre: 17
Each genre has a number. Rock = 17, Hip Hop = 125, etcetera.
What I need is: if the script puts out number 17, it has to display 'ROCK', and if it puts out 125, it has to display 'HIPHOP'.
Does anyone know how I can do all this? There's about 150 genre's so keeping the scriptsize to a minimum would be preferable.