diff --git a/src/howler.core.js b/src/howler.core.js index e02e0ab9..4a0dad8d 100644 --- a/src/howler.core.js +++ b/src/howler.core.js @@ -2007,10 +2007,21 @@ */ _endListener: function() { var self = this; + var parent = self._parent; + + // This event should fire only when the audio ended despite being marked infinite by the browser + if (parent._duration === Infinity) { + + // Update the parent duration to match the real audio duration + // Round up the duration to account for the lower precision in HTML5 Audio. + parent._duration = Math.ceil(self._node.duration * 10) / 10; + + // Setup a sprite that corresponds to the real duration. + if (parent._sprite.__default[1] === Infinity) { + parent._sprite.__default[1] = parent._duration * 1000; + } - // Fire an end event - the duration should have been infinite but the audio ended anyways. - if (self._parent._duration === Infinity) { - self._parent._ended(self); + parent._ended(self); } // Clear the event listener.