audio duration js NaN code example
Example: 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;
_player.volume = 0;
_player.play();
};
getDuration ('/path/to/audio/file', function (duration) {
console.log(duration);
});