Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get a sounds length (duration) in javascript

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?

like image 607
crazyosachou Avatar asked Jan 10 '23 07:01

crazyosachou


1 Answers

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.

like image 176
James Simpson Avatar answered Jan 17 '23 14:01

James Simpson