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.

Located in /ID3v2.php (line 71)


	
			
Method Summary
ID3v2 __construct ([string|Reader $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)
boolean __isset (string $name)
string __toString ()
void __unset (string $name)
Methods
Constructor __construct (line 113)

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.
  • readonly -- Indicates that the tag is read from a temporary file or another source it cannot be written back to. The tag can, however, still be written to another file.

  • 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|Reader $filename = false], [Array $options = array()])
  • string|Reader $filename: The path to the file, file descriptor of an opened file, or Reader instance.
  • Array $options: The options array.
addFrame (line 283)

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 307)

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 265)

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 297)

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 319)

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 348)

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 397)

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.
__isset (line 417)

Magic function so that isset($obj->value) will work. This method checks whether the frame matching the identifier exists.

  • access: public
boolean __isset (string $name)
  • string $name: The frame identifier.
__toString (line 435)

Returns the tag raw data.

  • access: public
string __toString ()
__unset (line 428)

Magic function so that unset($obj->value) will work. This method removes all the frames matching the identifier.

  • access: public
void __unset (string $name)
  • string $name: The frame identifier.

Documentation generated on Fri, 05 Sep 2008 20:18:50 +0300 by phpDocumentor 1.4.1