最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

audio - Get a sounds length (duration) in javascript - Stack Overflow

programmeradmin0浏览0评论

I am using howler.js to manage sounds within my html/css/js project, everything is working fine, the only point that took me hours of research without success is: How can I get the length of a sound using howler.js methods?

I am using howler.js to manage sounds within my html/css/js project, everything is working fine, the only point that took me hours of research without success is: How can I get the length of a sound using howler.js methods?

Share Improve this question edited Jul 3, 2014 at 9:57 crazyosachou asked Jul 2, 2014 at 18:42 crazyosachoucrazyosachou 591 silver badge6 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 9

Using howler.js, you can simply do the following:

sound._duration

You may also want to wrap that inside of the onload event as you won't be able to get the duration until the sound has loaded.

Without any library I would reend using .duration property of your audio element. which returns the amount of seconds that the audio should play.

发布评论

评论列表(0)

  1. 暂无评论