Home  >  Article  >  php教程  >  PHP获取音乐文件播放总时间

PHP获取音乐文件播放总时间

PHP中文网
PHP中文网Original
2016-05-25 17:08:591363browse

[代码][PHP]代码 

/*
* @Author : PHP中文网
*
**/
<?php
// mp3, wav 或者其他 media player 支持的格式.
$file = realpath("1.mp3"); 
$player= new COM("WMPlayer.OCX");
$media = $player->newMedia($file);
$time=$media->duration;   // “单位/秒”
$h=floor($time/3600);
$m=floor(($time %3600)/60);
$s=floor($time-$h*3600-$m*60);
echo $h."小时".$m."分".$s."秒";
?>


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn