Home >Backend Development >PHP Tutorial >Get the playback time of music files in php_PHP tutorial
The article briefly introduces the PHP music file playback time code. Friends in need can take a closer look. // mp3, wav or other formats supported by media player.
代码如下 | 复制代码 |
$file = "C:/Users/Public/Music/Sample Music/Kalimba.mp3"; if (!file_exists($file)) { exit('媒体文件不存在.'); } // 创建一个Windows Media Player接口 $player = new COM("WMPlayer.OCX"); $media = $player->newMedia($file); // 获取歌曲时间 (单位秒) echo $media->duration.'秒'; |