Answers for "javascript audio duration property returns infinity"

0

javascript audio duration property returns infinity

var getDuration = function (url, next) {
    var _player = new Audio(url);
    _player.addEventListener("durationchange", function (e) {
        if (this.duration!=Infinity) {
           var duration = this.duration
           _player.remove();
           next(duration);
        };
    }, false);      
    _player.load();
    _player.currentTime = 24*60*60; //fake big time
    _player.volume = 0;
    _player.play();
    //waiting...
};

getDuration ('/path/to/audio/file', function (duration) {
    console.log(duration);
});
Posted by: Guest on August-11-2020

Code answers related to "javascript audio duration property returns infinity"

Code answers related to "Javascript"

Browse Popular Code Answers by Language