Skip to content

Commit afa56ea

Browse files
authored
Fix a bug with AudioBufferSourceNode
goldfire#226 It seems as though AudioBufferSourceNode can get caught in cases where the seek and duration are negative "Failed to execute 'start' on 'AudioBufferSourceNode': The duration provided (-0.17) is less than the minimum bound (0)" We can protect this by defaulting to 0 when we seek or set a duration below 0.
1 parent 6d82d15 commit afa56ea

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/howler.core.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -623,8 +623,8 @@
623623
}
624624

625625
// Determine how long to play for and where to start playing.
626-
var seek = sound._seek > 0 ? sound._seek : self._sprite[sprite][0] / 1000;
627-
var duration = ((self._sprite[sprite][0] + self._sprite[sprite][1]) / 1000) - seek;
626+
var seek = Math.max(0, sound._seek > 0 ? sound._seek : self._sprite[sprite][0] / 1000);
627+
var duration = Math.max(0, ((self._sprite[sprite][0] + self._sprite[sprite][1]) / 1000) - seek);
628628
var timeout = (duration * 1000) / Math.abs(sound._rate);
629629

630630
// Update the parameters of the sound

0 commit comments

Comments
 (0)