laoqianjunzi / getid3
GetId3 库的分支更新为 PSR-2 / PSR-4 CS,添加了命名空间,并通过 composer 可安装。
1.0
2023-09-20 09:56 UTC
Requires
- php: >=5.3
Suggests
- ext-exif: EXIF extension is required for graphic modules.
- ext-rar: RAR extension is required for RAR archive module.
This package is not auto-updated.
Last update: 2024-09-19 12:48:38 UTC
README
GetId3
有用链接
许可证
有关许可证信息,请阅读 Resources/doc/license.txt
有关商业许可证,请阅读 Resources/doc/license.commercial.txt
通过 composer 安装
运行 composer 安装库
$ composer require "laoqianjunzi/getid3: ~2.1"
快速使用示例:读取音频属性
<?php
namespace My\Project;
use GetId3\GetId3Core;
class MyClass
{
// ...
private function myMethod()
{
$mp3File = '/path/to/my/mp3file.mp3';
$getId3 = new GetId3Core();
$audio = $getId3
->setOptionMD5Data(true)
->setOptionMD5DataSource(true)
->setEncoding('UTF-8')
->analyze($mp3File)
;
if (isset($audio['error'])) {
throw new \RuntimeException(sprintf('Error at reading audio properties from "%s" with GetId3: %s.', $mp3File, $audio['error']));
}
$this->setLength(isset($audio['playtime_seconds']) ? $audio['playtime_seconds'] : '');
// var_dump($audio);
}
}