Home » File Formats » MP3_Id » Manual
This package offers methods for reading and writing IDv1-information tags of MP3 files.
Constants
Constants – Constants defined in and used by MP3_Id
All Constants
Constants defined in Id.php
| Name | Value | Meaning |
|---|---|---|
| PEAR_MP3_ID_FNO | 1 | Error code: file not found |
| PEAR_MP3_ID_NOMP3 | 4 | Error code: file is not a MP3 file |
| PEAR_MP3_ID_RE | 2 | Error code: read error |
| PEAR_MP3_ID_TNF | 3 | Error code: Tag not found |
MP3_Id::MP3_Id
MP3_Id::MP3_Id() – constructor
Synopsis
require_once 'Id.php';
void MP3_Id::MP3_Id (
boolean $study
= false
)
Description
Constructor
Parameter
-
boolean
$study -
Enables an in-deep look in the file (increase execution time!)
Note
This function can not be called statically.
MP3_Id::copy
MP3_Id::copy() – copy the tags of another instance
Synopsis
require_once 'Id.php';
void MP3_Id::copy (
string $from
)
Description
Sets the ID3 tags to the same as the tags in
$from
Parameter
-
string
$from -
Name of the variable storing an other instance of MP3_Id
Note
This function can not be called statically.
MP3_Id::genres
MP3_Id::genres() – get Genre list
Synopsis
require_once 'Id.php';
array MP3_Id::genres (
)
Description
Returns a list of genre numbers and names
Return value
array - list of genres
Note
This function can not be called statically.
MP3_Id::getGenre
MP3_Id::getGenre() – return genre name by number
Synopsis
require_once 'Id.php';
mixed MP3_Id::getGenre (
integer $genreno
)
Description
Return the name of a genre number, if no genre number is specified the genre number found in the file will be used.
Parameter
-
integer
$genreno -
Number of the genre
Return value
mixed FALSE, if no genre found, else string
Note
This function can not be called statically.
MP3_Id::getGenreNo
MP3_Id::getGenreNo() – get number of genre
Synopsis
require_once 'Id.php';
integer MP3_Id::getGenreNo (
string $genre
, integer $default = 0xff
)
Description
Get the number of a genre.
Parameter
-
string
$genre -
Name of the genre
-
integer
$default -
The value to return in case of genre not found
Note
This function can not be called statically.
MP3_Id::getTag
MP3_Id::getTag() – get the value of a tag
Synopsis
require_once 'Id.php';
mixed MP3_Id::getTag (
string $name
, mixed $default
)
Description
Get the value of a tag
Parameter
-
string
$name -
the name of the tag to get
-
mixed
$default -
returned, if the tag not exists
Return value
mixed The value of the field
See
Note
This function can not be called statically.
MP3_Id::read
MP3_Id::read() – reads and parses file
Synopsis
require_once 'Id.php';
void MP3_Id::read (
string $file
)
Description
Reads the given file and parses it.
Parameter
-
string
$file -
the name of the file to parse
Throws
| Error code | Error message | Reason | Solution |
|---|---|---|---|
| PEAR_MP3_ID_FNO | "Unable to open $file" | The provide file name could not be opened | The file is currently write protected or doesn't exists. |
| PEAR_MP3_ID_RE | "Unable to see to end - 128 of $file" or "Unable to see to end of $file" | A read error occured | The file is too short or empty - not a MP3 file or a corrupted one. |
Note
This function can not be called statically.
MP3_Id::remove
MP3_Id::remove() – remove tags
Synopsis
require_once 'Id.php';
void MP3_Id::remove (
boolean $id3v1
= true
, boolean $id3v2
= true
)
Description
Removes all tags from a file.
Parameter
-
boolean
$id3v1 -
TRUE to remove tags
-
boolean
$id3v2 -
unused
Throws
| Error code | Error message | Reason | Solution |
|---|---|---|---|
| PEAR_MP3_ID_FNO | "Unable to open $file" | The provide file name could not be opened | The file is currently write protected or doesn't exists. |
| PEAR_MP3_ID_RE | "Unable to see to end - 128 of $file" or "Unable to see to end of $file" | A read error occured | The file is too short or empty - not a MP3 file or a corrupted one. |
Note
This function can not be called statically.
MP3_Id::setTag
MP3_Id::setTag() – sets a tag content
Synopsis
require_once 'Id.php';
void MP3_Id::setTag (
mixed $name
, mixed $value
)
Description
Sets a field
| Tag | Meaning |
|---|---|
| name | Title of the content |
| artists | Name of band or artist |
| album | Name of the album |
| year | publishing year of the album or song |
| comment | song comment |
| track | the number of the track |
| genre | genre of the song |
| genreno | Number of the genre |
Parameter
-
mixed
$name -
Name of the tag to set or hash with the key as fieldname
-
mixed
$value -
the value to set
Note
This function can not be called statically.
MP3_Id::study
MP3_Id::study() – does extra work to get the MPEG frame info
Synopsis
require_once 'Id.php';
void MP3_Id::study (
void
)
Description
Does extra work to get the MPEG frame info.
Throws
| Error code | Error message | Reason | Solution |
|---|---|---|---|
| PEAR_MP3_ID_NOMP3 | "No mpeg frame found" | The file have no MP3 file structure. | The file is not a MP3 file. |
Note
This function can not be called statically.
MP3_Id::write
MP3_Id::write() – save changed tags
Synopsis
require_once 'Id.php';
void MP3_Id::write (
boolean $v1
= true
)
Description
Updates the tags on the file.
Parameter
-
boolean
$v1 -
if TRUE update/create an Version 1-tag on the file
Throws
| Error code | Error message | Reason | Solution |
|---|---|---|---|
| PEAR_MP3_ID_FNO | "Unable to open $file" | The provide file name could not be opened | The file is currently write protected or doesn't exists. |
| PEAR_MP3_ID_RE | "Unable to see to end - 128 of $file" or "Unable to see to end of $file" | A read error occured | The file is too short or empty - not a MP3 file or a corrupted one. |
Note
This function can not be called statically.