我怎样才能获得HTML5音频的持续时间 [英] How can I get the html5 audio's duration time

查看:122
本文介绍了我怎样才能获得HTML5音频的持续时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个HTML5 <音频> 页面标签,但我怎么能知道它的持续时间

 <音响控制=>
    <信源SRC =p4.2.mp3>
< /音频>


解决方案

哪个浏览器,你想这个吗?在某些浏览器持续时间不会,因为它应该回到正常工作 NaN的你所说的。

此外,你确保音频文件已经试图检索期限之前加载?

I have a html5 <audio> tag in page, but how can I know its duration time?

<audio controls="">
    <source src="p4.2.mp3">
</audio>

解决方案

Which browser are you trying this on? On some browsers duration doesn't work as it should, returning NaN as you mentioned.

Also are you ensuring that the audio file has loaded before attempting to retrieve the duration?

这篇关于我怎样才能获得HTML5音频的持续时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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