KTaglib

目录

简介

Represents an MPEG file. MPEG files can have ID3v1, ID3v2 tags and audio properties.

Class synopsis

KTaglib_MPEG_File

class KTaglib_MPEG_File {

/* 方法 */

public KTaglib_MPEG_File getAudioProperties ( void )

public KTaglib_ID3v1_Tag getID3v1Tag ([ bool $create = FALSE ] )

public KTaglib_ID3v2_Tag getID3v2Tag ([ bool $create = FALSE ] )

}

KTaglib_MPEG_File::__construct

Opens a new file

说明

public KTaglib_MPEG_File::__construct ( string $filename )

Opens a new MPEG file.

参数

filename
The file to read

范例

示例 #1 Opens a new MP3 file and read the title

<?php
$mpeg = new KTaglib_MPEG_File('example.mp3');
echo $mpeg->getID3v1Tag()->getTitle();
?>

KTaglib_MPEG_File::getAudioProperties

Returns an object that provides access to the audio properties

说明

public KTaglib_MPEG_File KTaglib_MPEG_File::getAudioProperties ( void )

Returns an object that provides access to the audio properties of the mpeg file.

返回值

Returns an KTaglib_MPEG_AudioProperties object or false.

KTaglib_MPEG_File::getID3v1Tag

Returns an object representing an ID3v1 tag

说明

public KTaglib_ID3v1_Tag KTaglib_MPEG_File::getID3v1Tag ([ bool $create = FALSE ] )

Returns an object that represents an ID3v1 tag, which can be used to get information about the ID3v1 tag.

返回值

Returns an KTaglib_MPEG_ID3v1Tag object or false if there is no ID3v1 tag.

KTaglib_MPEG_File::getID3v2Tag

Returns a ID3v2 object

说明

public KTaglib_ID3v2_Tag KTaglib_MPEG_File::getID3v2Tag ([ bool $create = FALSE ] )

Returns a ID3v2 object for the mpeg file. If no ID3v2 Tag is present, an KTaglib_TagNotFoundException is thrown.

返回值

Returns the KTaglib_ID3v2_Tag object of the MPEG file or false if there is no ID3v2 tag

简介

Represents the audio properties of a MPEG file, like length, bitrate or samplerate.

Class synopsis

KTaglib_MPEG_Audioproperties

class KTaglib_MPEG_AudioProperties {

/* 方法 */

public int KTaglib_MPEG_AudioProperties::getBitrate ( void )

public int KTaglib_MPEG_AudioProperties::getChannels ( void )

public int KTaglib_MPEG_AudioProperties::getLayer ( void )

public int KTaglib_MPEG_AudioProperties::getLength ( void )

public int KTaglib_MPEG_AudioProperties::getSampleBitrate ( void )

public int KTaglib_MPEG_AudioProperties::getVersion ( void )

public bool KTaglib_MPEG_AudioProperties::isCopyrighted ( void )

public bool KTaglib_MPEG_AudioProperties::isOriginal ( void )

public bool KTaglib_MPEG_AudioProperties::isProtectionEnabled ( void )

}

KTaglib_MPEG_AudioProperties::getBitrate

Returns the bitrate of the MPEG file

说明

public int KTaglib_MPEG_AudioProperties::getBitrate ( void )

Returns the bitrate of the MPEG file

返回值

Returns the bitrate as an integer

KTaglib_MPEG_AudioProperties::getChannels

Returns the amount of channels of a MPEG file

说明

public int KTaglib_MPEG_AudioProperties::getChannels ( void )

Returns the amount of channels of the MPEG file

返回值

Returns the channel count as an integer

KTaglib_MPEG_AudioProperties::getLayer

Returns the layer of a MPEG file

说明

public int KTaglib_MPEG_AudioProperties::getLayer ( void )

Returns the layer of the MPEG file (usually 3 for MP3).

返回值

Returns the layer as an integer

KTaglib_MPEG_AudioProperties::getLength

Returns the length of a MPEG file

说明

public int KTaglib_MPEG_AudioProperties::getLength ( void )

Returns the length of the MPEG file

返回值

Returns the length as an integer

KTaglib_MPEG_AudioProperties::getSampleBitrate

Returns the sample bitrate of a MPEG file

说明

public int KTaglib_MPEG_AudioProperties::getSampleBitrate ( void )

Returns the sample bitrate of the MPEG file

返回值

Returns the sample bitrate as an integer

KTaglib_MPEG_AudioProperties::getVersion

Returns the version of a MPEG file

说明

public int KTaglib_MPEG_AudioProperties::getVersion ( void )

Returns the version of the MPEG file header. The possible versions are defined in Tag_MPEG_Header (Version1, Version2, Version2.5).

返回值

Returns the version

KTaglib_MPEG_AudioProperties::isCopyrighted

Returns the copyright status of an MPEG file

说明

public bool KTaglib_MPEG_AudioProperties::isCopyrighted ( void )

Returns true if the MPEG file is copyrighted

返回值

Returns true if the MPEG file is copyrighted

KTaglib_MPEG_AudioProperties::isOriginal

Returns if the file is marked as the original file

说明

public bool KTaglib_MPEG_AudioProperties::isOriginal ( void )

Returns true if the file is marked as the original file

返回值

Returns true if the file is marked as the original file

KTaglib_MPEG_AudioProperties::isProtectionEnabled

Returns if protection mechanisms of an MPEG file are enabled

说明

public bool KTaglib_MPEG_AudioProperties::isProtectionEnabled ( void )

Returns true if protection mechanisms (like DRM) are enabled for this file

返回值

Returns true if protection mechanisms (like DRM) are enabled for this file

简介

Base class for ID3v1 or ID3v2 tags

Class synopsis

KTaglib_Tag

class KTaglib_Tag {

/* 方法 */

public string getAlbum ( void )

public string getArtist ( void )

public string getComment ( void )

public string getGenre ( void )

public string getTitle ( void )

public int getTrack ( void )

public int getYear ( void )

public bool isEmpty ( void )

}

KTaglib_Tag::getAlbum

Returns the album string from a ID3 tag

说明

public string KTaglib_Tag::getAlbum ( void )

Returns the album string of an ID3 tag. This method is implemented in ID3v1 and ID3v2 tags.

返回值

Returns the album string

KTaglib_Tag::getArtist

Returns the artist string from a ID3 tag

说明

public string KTaglib_Tag::getArtist ( void )

Returns the artist string of an ID3 tag. This method is implemented in ID3v1 and ID3v2 tags.

返回值

Returns the artist string

KTaglib_Tag::getComment

Returns the comment from a ID3 tag

说明

public string KTaglib_Tag::getComment ( void )

Returns the comment of an ID3 tag. This method is implemented in ID3v1 and ID3v2 tags.

返回值

Returns the comment string

KTaglib_Tag::getGenre

Returns the genre from a ID3 tag

说明

public string KTaglib_Tag::getGenre ( void )

Returns the genre of an ID3 tag. This method is implemented in ID3v1 and ID3v2 tags.

返回值

Returns the genre string

KTaglib_Tag::getTitle

Returns the title string from a ID3 tag

说明

public string KTaglib_Tag::getTitle ( void )

Returns the title string of an ID3 tag. This method is implemented in ID3v1 and ID3v2 tags.

返回值

Returns the title string

KTaglib_Tag::getTrack

Returns the track number from a ID3 tag

说明

public int KTaglib_Tag::getTrack ( void )

Returns the track number of an ID3 tag. This method is implemented in ID3v1 and ID3v2 tags.

返回值

Returns the track number as an integer

KTaglib_Tag::getYear

Returns the year from a ID3 tag

说明

public int KTaglib_Tag::getYear ( void )

Returns the year of an ID3 tag. This method is implemented in ID3v1 and ID3v2 tags.

返回值

Returns the year as an integer

KTaglib_Tag::isEmpty

Returns true if the tag is empty

说明

public bool KTaglib_Tag::isEmpty ( void )

Returns true if the tag exists, but is empty. This method is implemented in ID3v1 and ID3v2 tags.

返回值

Returns true if the tag is empty, otherwise false.

简介

Represents and ID3v2 tag. It provides a list of ID3v2 frames and can be used to add and remove additional frames.

Class synopsis

KTaglib_ID3v2_Tag

extends class KTaglib_Tag {

/* 方法 */

public bool addFrame ( KTaglib_ID3v2_Frame $frame )

public array getFrameList ( void )

/* 继承的方法 */

public string KTaglib_Tag::getAlbum ( void )

public string KTaglib_Tag::getArtist ( void )

public string KTaglib_Tag::getComment ( void )

public string KTaglib_Tag::getGenre ( void )

public string KTaglib_Tag::getTitle ( void )

public int KTaglib_Tag::getTrack ( void )

public int KTaglib_Tag::getYear ( void )

public bool KTaglib_Tag::isEmpty ( void )

}

KTaglib_ID3v2_Tag::addFrame

Add a frame to the ID3v2 tag

说明

public bool KTaglib_ID3v2_Tag::addFrame ( KTaglib_ID3v2_Frame $frame )

Adds a frame to the ID3v2 tag. The frame must be a valid KTaglib_ID3v2_Frame object. To save the tag, the save function needs to be invoked.

返回值

Returns true on success, otherwise false.

KTaglib_ID3v2_Tag::getFrameList

Returns an array of ID3v2 frames, associated with the ID3v2 tag

说明

public array KTaglib_ID3v2_Tag::getFrameList ( void )

Returns an array of ID3v2 frames, associated with the ID3v2 tag.

返回值

Return an array of KTaglib_ID3v2_Frame objects

简介

The base class for ID3v2 frames. ID3v2 tags are separated in various specialized frames. Some frames can exists multiple times.

Class synopsis

KTaglib_ID3v2_Frame

extends class KTaglib_Tag {

/* 方法 */

public int getSize ( void )

public string __toString ( void )

/* 继承的方法 */

public string KTaglib_Tag::getAlbum ( void )

public string KTaglib_Tag::getArtist ( void )

public string KTaglib_Tag::getComment ( void )

public string KTaglib_Tag::getGenre ( void )

public string KTaglib_Tag::getTitle ( void )

public int KTaglib_Tag::getTrack ( void )

public int KTaglib_Tag::getYear ( void )

public bool KTaglib_Tag::isEmpty ( void )

}

KTaglib_ID3v2_Frame::getSize

Returns the size of the frame in bytes

说明

public int KTaglib_ID3v2_Frame::getSize ( void )

Returns the size of the frame in bytes. Please refer to id3.org to see what ID3v2 frames are and how they are defined.

返回值

Returns the size of the frame in bytes

KTaglib_ID3v2_Frame::__toString

Returns a string representation of the frame

说明

public string KTaglib_ID3v2_Frame::__toString ( void )

Returns a string representation of the frame. This might be just the frame id, but might contain more information. Please see the ktaglib documentation for more information

返回值

Returns a string representation of the frame.

简介

Represents an ID3v2 frame that can hold a picture.

Class synopsis

KTaglib_ID3v2_AttachedPictureFrame

extends class KTaglib_ID3v2_Frame {

/* 方法 */

public string getDescription ( void )

public string getMimeType ( void )

public int getType ( void )

public bool savePicture ( string $filename )

public string getMimeType ( string $type )

public void setPicture ( string $filename )

public void setType ( int $type )

/* 继承的方法 */

public int KTaglib_ID3v2_Frame::getSize ( void )

public string KTaglib_ID3v2_Frame::__toString ( void )

public string KTaglib_Tag::getAlbum ( void )

public string KTaglib_Tag::getArtist ( void )

public string KTaglib_Tag::getComment ( void )

public string KTaglib_Tag::getGenre ( void )

public string KTaglib_Tag::getTitle ( void )

public int KTaglib_Tag::getTrack ( void )

public int KTaglib_Tag::getYear ( void )

public bool KTaglib_Tag::isEmpty ( void )

}

KTaglib_ID3v2_AttachedPictureFrame::getDescription

Returns a description for the picture in a picture frame

说明

public string KTaglib_ID3v2_AttachedPictureFrame::getDescription ( void )

Returns the attached description for a picture frame in an ID3v2.x frame.

返回值

Returns a description for the picture in a picture frame

KTaglib_ID3v2_AttachedPictureFrame::getMimeType

Returns the mime type of the picture

说明

public string KTaglib_ID3v2_AttachedPictureFrame::getMimeType ( void )

Returns the mime type of the image represented by the attached picture frame.

Please notice that this method might return different types. While ID3v2.2 have a mime type that doesn't start with "image/", ID3v2.3 and v2.4 usually start with "image/". Therefore the method might return "image/png" for IDv2.3 frames and just "PNG" for ID3v2.2 frames.

Notice that even the frame is an attached picture, the mime type might not be set and therefore an empty string might be returned.

返回值

Returns the mime type of the image represented by the attached picture frame.

KTaglib_ID3v2_AttachedPictureFrame::getType

Returns the type of the image

说明

public int KTaglib_ID3v2_AttachedPictureFrame::getType ( void )

Returns the type of the image.

The ID3v2 specification allows an AttachedPictureFrame to set the type of an image. This can be e.g. FrontCover or FileIcon. Please refer to the KTaglib_ID3v2_AttachedPictureFrame class description for a list of available types.

返回值

Returns the integer representation of the type.

KTaglib_ID3v2_AttachedPictureFrame::savePicture

Saves the picture to a file

说明

public bool KTaglib_ID3v2_AttachedPictureFrame::savePicture ( string $filename )

Saves the attached picture to the given filename.

返回值

Returns true on success, otherwise false

KTaglib_ID3v2_AttachedPictureFrame::setMimeType

Set's the mime type of the picture

说明

public string KTaglib_ID3v2_AttachedPictureFrame::getMimeType ( string $type )

Sets the mime type of the image. This should in most cases be "image/png" or "image/jpeg".

KTaglib_ID3v2_AttachedPictureFrame::setPicture

Sets the frame picture to the given image

说明

public void KTaglib_ID3v2_AttachedPictureFrame::setPicture ( string $filename )

Sets the picture to the give image. The image is loaded from the given filename. Please note that the picture is not saved unless you call the save method of the corresponding file object.

返回值

Returns true on success, otherwise false

KTaglib_ID3v2_AttachedPictureFrame::setType

Set the type of the image

说明

public void KTaglib_ID3v2_AttachedPictureFrame::setType ( int $type )

Sets the type of the image. This can be e.g. FrontCover or FileIcon. Please refer to the KTaglib_ID3v2_AttachedPictureFrame class description for a list of available types and their constant mappings.