转换MP3持续时间 [英] Converting MP3 duration time

查看:109
本文介绍了转换MP3持续时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用iTunes库从大约1100 mp3中获取数据,但是在使库的持续时间达到数分钟和数秒时遇到了一个小问题.

I'm using my iTunes library to get data from about 1,100 mp3s and I'm running into a small issue in getting the duration of the library into minutes and seconds.

$duration = 1893642;
$minutes = bcmod(($duration / 60), 60);
$seconds = bcmod($duration, 60);
echo $minutes.":".$seconds; //returns 0:42

问题在于此特定的MP3实际上是31:42.有什么想法为什么不起作用?

The problem is that this specific MP3 is actually 31:42. Any thoughts on why this isn't working?

推荐答案

$minutes = bcmod(($duration / 60), 60);

将分钟取模60.除非您的音轨超过一个小时,否则总会说0. 您希望它成为

is taking the minutes modulo 60. Unless your track is over an hour it will always say 0. You want it to be

$minutes = floor($duration / 60);

这篇关于转换MP3持续时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆