实现php获取mp3文件元信息如播放时间歌曲作者等
最近收集到一个php获取mp3文件元信息的类,感觉比较方便。现在分享给大家!
下面是使用方式和测试方式:
<?php include_once 'mp3file.class.php'; function mp3Time($file) { $m = new mp3file($file); $a = $m->get_metadata(); return $a['Length mm:ss'] ? $a['Length mm:ss'] : 0; } function mp3Info($file) { $m = new mp3file($file); return $m->get_metadata(); } $_time = mp3Time('3.mp3'); echo '<meta charset="UTF-8">'; echo "歌曲时间长:".$_time.'<br />'; $_info = mp3Info('3.mp3'); print_r($_info); ?>
mp3file.class.php这个文件请下载附件