Class ID3v2

Description

This class represents a file containing ID3v2 headers as described in ID3v2 structure document.

ID3v2 is a general tagging format for audio, which makes it possible to store meta data about the audio inside the audio file itself. The ID3 tag is mainly targeted at files encoded with MPEG-1/2 layer I, MPEG-1/2 layer II, MPEG-1/2 layer III and MPEG-2.5, but may work with other types of encoded audio or as a stand alone format for audio meta data.

ID3v2 is designed to be as flexible and expandable as possible to meet new meta information needs that might arise. To achieve that ID3v2 is constructed as a container for several information blocks, called frames, whose format need not be known to the software that encounters them. Each frame has an unique and predefined identifier which allows software to skip unknown frames.

Overall tag structure:

   +-----------------------------+
   |      Header (10 bytes)      |
   +-----------------------------+
   |       Extended Header       |
   | (variable length, OPTIONAL) |
   +-----------------------------+
   |   Frames (variable length)  |
   +-----------------------------+
   |           Padding           |
   | (variable length, OPTIONAL) |
   +-----------------------------+
   | Footer (10 bytes, OPTIONAL) |
   +-----------------------------+

In general, padding and footer are mutually exclusive.

Located in /ID3v2.php (line 90)


	
			
Method Summary
ID3v2 __construct ([string $filename = false], [Array $options = array()])
Array getFrames ()
Array getFramesByIdentifier ( $identifier)
boolean hasExtendedHeader ()
boolean hasFooter ()
boolean hasFrame ( $identifier)
void setExtendedHeader (ID3_ExtendedHeader $extendedHeader)
void setFooter (boolean $useFooter)
void write ([string $filename = false])
mixed __get (string $name)
string __toString ()
Methods
Constructor __construct (line 128)

Constructs the ID3v2 class with given file and options. The options array may also be given as the only parameter.

The following options are currently recognized:

  • version -- The ID3v2 tag version to use in write operation. This option is automatically set when a tag is read from a file and defaults to version 4.0 for tag write.

  • todo: Only limited subset of flags are processed.
  • todo: Utilize the SEEK frame and search for a footer to find the tag
  • todo: Utilize the LINK frame to fetch frames from other sources
  • access: public
ID3v2 __construct ([string $filename = false], [Array $options = array()])
  • string $filename: The path to the file.
  • Array $options: The options array.
addFrame (line 286)

Adds a new frame to the tag and returns it.

  • access: public
ID3_Frame addFrame (ID3_Frame $frame)
getExtendedHeader (line 209)

Returns the extended header object if present, or false otherwise.

  • access: public
ID3_ExtendedHeader|false getExtendedHeader ()
getFooter (line 310)

Returns the footer object if present, or false otherwise.

  • access: public
ID3_Header|false getFooter ()
getFrames (line 249)

Returns all the frames the tag contains as an associate array. The frame identifiers work as keys having an array of frames as associated value.

  • access: public
Array getFrames ()
getFramesByIdentifier (line 268)

Returns an array of frames matching the given identifier or an empty array if no frames matched the identifier.

The identifier may contain wildcard characters "*" and "?". The asterisk matches against zero or more characters, and the question mark matches any single character.

Please note that one may also use the shorthand $obj->identifier to access the first frame with the identifier given. Wildcards cannot be used with the shorthand.

  • access: public
Array getFramesByIdentifier ( $identifier)
  • $identifier
getHeader (line 189)

Returns the header object.

  • access: public
ID3_Header getHeader ()
hasExtendedHeader (line 197)

Checks whether there is an extended header present in the tag. Returns true if the header is present, false otherwise.

  • access: public
boolean hasExtendedHeader ()
hasFooter (line 300)

Checks whether there is a footer present in the tag. Returns true if the footer is present, false otherwise.

  • access: public
boolean hasFooter ()
hasFrame (line 238)

Checks whether there is a frame given as an argument defined in the tag.

Returns true if one ore more frames are present, false otherwise.

  • access: public
boolean hasFrame ( $identifier)
  • $identifier
setExtendedHeader (line 221)

Sets the extended header object.

  • access: public
void setExtendedHeader (ID3_ExtendedHeader $extendedHeader)
setFooter (line 322)

Sets whether the tag should have a footer defined.

  • access: public
void setFooter (boolean $useFooter)
  • boolean $useFooter: Whether the tag should have a footer
write (line 351)

Writes the possibly altered ID3v2 tag back to the file where it was read.

If the class was constructed without a file name, one can be provided here as an argument. Regardless, the write operation will override previous tag information, if found.

If write is called without setting any frames to the tag, the tag is removed from the file.

  • access: public
void write ([string $filename = false])
  • string $filename: The optional path to the file.
__get (line 396)

Magic function so that $obj->value will work. The method will attempt to return the first frame that matches the identifier.

If there is no frame or field with given name, the method will attempt to create a frame with given identifier.

If none of these work, an exception is thrown.

  • access: public
mixed __get (string $name)
  • string $name: The frame or field name.
__toString (line 414)

Returns the tag raw data.

  • access: public
string __toString ()

Documentation generated on Tue, 15 Apr 2008 03:33:11 +0300 by phpDocumentor 1.4.1