xylphid/php-id3

ID3标签读取器/写入器

1.0.2 2023-03-15 11:44 UTC

This package is not auto-updated.

Last update: 2024-09-25 18:57:10 UTC


README

PHP-ID3 是一个用于 ID3 标签的本地 PHP 库

兼容性

PHP-ID3 已在以下 PHP 版本上进行了测试

  • PHP 8.2

安装

composer install xylphid/php-id3

使用

PHP 脚本

逐步提取

use Id3\Id3;

$media = '/path/to/media/file.mp3';
$id3 = new Id3Parser();
$id3->setFilename($media);
$id3->processFile();

自动处理

$media = '/path/to/media/file.mp3';
$id3 = new Id3Parser($media);

找到的标签被注册为对象属性,并按照 Id3 规范命名。您可以使用以下方式显示标签:

if ($id3->isCompliant()) {
    printf("Title : %s\n", $id3->getTitle());
    printf("Artist : %s\n", $id3->getArtist());
    printf("Album : %s\n", $id3->getAlbum());
    printf("Track : %s\n", $id3->getTrack());
    printf("PartOfSet : %s\n", $id3->getPartOfSet());
    printf("Genre : %s\n", $id3->getGenre());
    printf("Year : %s\n", $id3->getYear());
    printf("Duration : %s\n", $id3->getDuration())
}