From afa56ea90baf84b8e0532e8eb604701526fdc5a4 Mon Sep 17 00:00:00 2001 From: Fabio Elia Date: Thu, 10 Nov 2016 15:49:18 -0500 Subject: [PATCH] Fix a bug with AudioBufferSourceNode https://github.com/goldfire/howler.js/issues/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. --- src/howler.core.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/howler.core.js b/src/howler.core.js index 641bf238..a6ebebfd 100644 --- a/src/howler.core.js +++ b/src/howler.core.js @@ -623,8 +623,8 @@ } // Determine how long to play for and where to start playing. - var seek = sound._seek > 0 ? sound._seek : self._sprite[sprite][0] / 1000; - var duration = ((self._sprite[sprite][0] + self._sprite[sprite][1]) / 1000) - seek; + var seek = Math.max(0, sound._seek > 0 ? sound._seek : self._sprite[sprite][0] / 1000); + var duration = Math.max(0, ((self._sprite[sprite][0] + self._sprite[sprite][1]) / 1000) - seek); var timeout = (duration * 1000) / Math.abs(sound._rate); // Update the parameters of the sound