Skip to content

Commit 6f4dae3

Browse files
committed
Updates the parent info too
1 parent 457dcb6 commit 6f4dae3

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/howler.core.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2012,10 +2012,21 @@
20122012
*/
20132013
_endListener: function() {
20142014
var self = this;
2015+
var parent = self._parent;
2016+
2017+
// This event should fire only when the audio ended despite being marked infinite by the browser
2018+
if (parent._duration === Infinity) {
2019+
2020+
// Update the parent duration to match the real audio duration
2021+
// Round up the duration to account for the lower precision in HTML5 Audio.
2022+
parent._duration = Math.ceil(self._node.duration * 10) / 10;
2023+
2024+
// Setup a sprite that corresponds to the real duration.
2025+
if (parent._sprite.__default[1] === Infinity) {
2026+
parent._sprite.__default[1] = parent._duration * 1000;
2027+
}
20152028

2016-
// Fire an end event - the duration should have been infinite but the audio ended anyways.
2017-
if (self._parent._duration === Infinity) {
2018-
self._parent._ended(self);
2029+
parent._ended(self);
20192030
}
20202031

20212032
// Clear the event listener.

0 commit comments

Comments
 (0)