MP3_Id
[ class tree: MP3_Id ] [ index: MP3_Id ] [ all elements ]

Class: MP3_Id

Source Location: /MP3_Id-1.2.2/Id.php

Class Overview


A Class for reading/writing MP3 ID3 tags


Author(s):

Version:

  • $Id: Id.php 315617 2011-08-27 14:36:36Z alexmerz $

Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 84]
A Class for reading/writing MP3 ID3 tags

Note: This code doesn't try to deal with corrupt mp3s. So if you get incorrect length times or something else it may be your mp3. To fix just re-enocde from the CD. :~)

eg: require_once("MP3/Id.php"); $file = "Some Song.mp3";

$id3 = &new MP3_Id(); $id3->read($file); print_r($id3);

echo $id3->getTag('artists');

$id3->comment = "Be gentle with that file."; $id3->write(); $id3->read($file); print_r($id3 );

  • Author: Sandy McArthur Jr. <Leknor@Leknor.com>
  • Version: $Id: Id.php 315617 2011-08-27 14:36:36Z alexmerz $


[ Top ]


Class Variables

$album =  ''

[line 122]

album

Type:   string


[ Top ]

$artists =  ''

[line 117]

artists

Type:   string


[ Top ]

$bitrate =  0

[line 170]

version of bitrate

Type:   integer


[ Top ]

$comment =  ''

[line 132]

comment

Type:   string


[ Top ]

$copyright =  false

[line 230]

Copyrighted

Type:   string


[ Top ]

$crc =  false

[line 175]

Frames are crc protected?

Type:   boolean


[ Top ]

$debug =  false

[line 277]

print debugging info?

Type:   boolean


[ Top ]

$debugbeg =  '<DIV STYLE="margin: 0.5 em; padding: 0.5 em; border-width: thin; border-color: black; border-style: solid">'

[line 282]

print debugg

Type:   string


[ Top ]

$debugend =  '</DIV>'

[line 287]

print debugg

Type:   string


[ Top ]

$emphasis =  ''

[line 240]

Emphasis (also never used)

Type:   boolean


[ Top ]

$encoding_type =  0

[line 185]

encoding type (CBR or VBR)

Type:   string


[ Top ]

$error =  false

[line 271]

if any errors they will be here

Type:   string


[ Top ]

$file =  false

[line 90]

mp3/mpeg file name

Type:   boolean


[ Top ]

$filesize =  -1

[line 245]

Bytes in file

Type:   integer


[ Top ]

$frameoffset =  -1

[line 250]

Byte at which the first mpeg header was found

Type:   integer


[ Top ]

$frames =  0

[line 205]

number of MPEG audio frames

Type:   integer


[ Top ]

$frequency =  0

[line 180]

frequency

Type:   integer


[ Top ]

$genre =  ''

[line 142]

genre name

Type:   string


[ Top ]

$genreno =  255

[line 147]

genre number

Type:   integer


[ Top ]

$id3v1 =  false

[line 95]

ID3 v1 tag found? (also true if v1.1 found)

Type:   boolean


[ Top ]

$id3v2 =  false

[line 105]

ID3 v2 tag found? (not used yet)

Type:   boolean


[ Top ]

$id3v11 =  false

[line 100]

ID3 v1.1 tag found?

Type:   boolean


[ Top ]

$layer =  0

[line 165]

version of layer

Type:   integer


[ Top ]

$length =  false

[line 260]

length of mp3 format mm:ss

Type:   string


[ Top ]

$lengthh =  false

[line 255]

length of mp3 format hh:mm:ss

Type:   string


[ Top ]

$lengths =  false

[line 265]

length of mp3 in seconds

Type:   string


[ Top ]

$mode =  ''

[line 225]

Mode (Stero etc)

Type:   string


[ Top ]

$mpeg_ver =  0

[line 160]

version of mpeg

Type:   integer


[ Top ]

$musicsize =  -1

[line 200]

Bytes in file without tag overhead

Type:   integer


[ Top ]

$name =  ''

[line 112]

trackname

Type:   string


[ Top ]

$original =  false

[line 235]

On Original Media? (never used)

Type:   boolean


[ Top ]

$padding =  false

[line 215]

Frames padded

Type:   boolean


[ Top ]

$private =  false

[line 220]

private bit set

Type:   boolean


[ Top ]

$quality =  0

[line 210]

quality indicator (0% - 100%)

Type:   integer


[ Top ]

$samples =  0

[line 195]

samples in file

Type:   integer


[ Top ]

$samples_per_frame =  0

[line 190]

number of samples per MPEG audio frame

Type:   integer


[ Top ]

$studied =  false

[line 154]

Was the file studied to learn more info?

Type:   boolean


[ Top ]

$track =  0

[line 137]

track number

Type:   integer


[ Top ]

$year =  ''

[line 127]

year

Type:   string


[ Top ]



Method Detail

MP3_Id (Constructor)   [line 298]

MP3_Id MP3_Id( [ $study = false])


Parameters:

   $study     

[ Top ]

copy   [line 398]

void copy( string $from)

copy($from) - set's the ID3 fields to the same as the fields in $from
  • Access: public

Parameters:

string   $from     fields to copy

[ Top ]

genres   [line 1005]

void genres( )


[ Top ]

getGenre   [line 953]

mixed getGenre( integer $genreno)

getGenre - return the name of a genre number

if no genre number is specified the genre number from $this->genreno will be used.

the genre is returned or false if an error or not found no error message is ever returned

  • Return: false, if no genre found, else string
  • Access: public

Parameters:

integer   $genreno     Number of the genre

[ Top ]

getGenreNo   [line 980]

void getGenreNo( $genre, [ $default = 0xff])


Parameters:

   $genre     
   $default     

[ Top ]

getTag   [line 357]

mixed getTag( string $name, [mixed $default = 0])

get the value of a tag

Parameters:

string   $name     the name of the field to get
mixed   $default     returned if the field not exists

[ Top ]

read   [line 311]

mixed read( [string $file = ""])

reads the given file and parse it
  • Return: PEAR_Error on error
  • Access: public

Parameters:

string   $file     the name of the file to parse

[ Top ]

remove   [line 419]

void remove( [boolean $id3v1 = true], [boolean $id3v2 = true])

remove - removes the id3 tag(s) from a file.
  • Access: public

Parameters:

boolean   $id3v1     true to remove the tag
boolean   $id3v2     true to remove the tag (Not yet implemented)

[ Top ]

setTag   [line 337]

void setTag( mixed $name, mixed $value)

sets a field

possible names of tags are: 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

  • Access: public

Parameters:

mixed   $name     Name of the tag to set or hash with the key as fieldname
mixed   $value     the value to set

[ Top ]

study   [line 387]

void study( )

study() - does extra work to get the MPEG frame info.
  • Access: public

[ Top ]

write   [line 374]

void write( [boolean $v1 = true])

update the id3v1 tags on the file.

Note: If/when ID3v2 is implemented this method will probably get another parameters.

  • Access: public

Parameters:

boolean   $v1     if true update/create an id3v1 tag on the file. (defaults to true)

[ Top ]


Documentation generated on Mon, 29 Aug 2011 00:30:03 +0000 by phpDocumentor 1.4.3. PEAR Logo Copyright © PHP Group 2004.