Skip to content

Commit

Permalink
Updates the parent info too
Browse files Browse the repository at this point in the history
  • Loading branch information
golddranks committed Nov 26, 2016
1 parent 8067d78 commit 7c4cbfa
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/howler.core.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 7c4cbfa

Please sign in to comment.