- 下载三方类库getID3(),下载地址:https://codeload.github.com/JamesHeinrich/getID3/zip/master
- 将getID3文件夹,放入项目中
- 在控制层使用位置引入文件:
- 代码:
// 引入文件
require_once('lib/getID3/getid3/getid3.php');
// Copy remote file locally to scan with getID3()
$remotefilename = $audio_url;
if ($fp_remote = fopen($remotefilename, 'rb')) {
$localtempfilename = tempnam('/tmp', 'getID3');
if ($fp_local = fopen($localtempfilename, 'wb')) {
while ($buffer = fread($fp_remote, 8192)) {
fwrite($fp_local, $buffer);
}
fclose($fp_local);
// Initialize getID3 engine
$getID3 = new \getID3();
$ThisFileInfo = $getID3->analyze($localtempfilename);
// Delete temporary file
unlink($localtempfilename);
// var_dump($ThisFileInfo);exit;
$duration = $ThisFileInfo['playtime_seconds'];
var_dump((int)ceil($duration), $duration);exit;
}
fclose($fp_remote);
}
摘自:https://github.com/JamesHeinrich/getID3