From dc2e2bf54c8276bb84b6b75cefd0b27535a2d7cd Mon Sep 17 00:00:00 2001 From: Cliffmeister Date: Mon, 10 Apr 2017 10:52:37 +0800 Subject: [PATCH] Fix for Howl's stop method (webAudio) The previous behavior has the method return immediately if sound._node.bufferSource is null, preventing the rest of the sounds in the group to be stopped. --- src/howler.core.js | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/src/howler.core.js b/src/howler.core.js index 2c811a65..d9822530 100644 --- a/src/howler.core.js +++ b/src/howler.core.js @@ -890,32 +890,27 @@ if (sound._node) { if (self._webAudio) { - // make sure the sound has been created - if (!sound._node.bufferSource) { - if (!internal) { - self._emit('stop', sound._id); - } + // make sure the sound's AudioBufferSourceNode has been created + if (sound._node.bufferSource) { - return self; - } + if (typeof sound._node.bufferSource.stop === 'undefined') { + sound._node.bufferSource.noteOff(0); + } else { + sound._node.bufferSource.stop(0); + } - if (typeof sound._node.bufferSource.stop === 'undefined') { - sound._node.bufferSource.noteOff(0); - } else { - sound._node.bufferSource.stop(0); + // Clean up the buffer source. + self._cleanBuffer(sound._node); } - - // Clean up the buffer source. - self._cleanBuffer(sound._node); } else if (!isNaN(sound._node.duration) || sound._node.duration === Infinity) { sound._node.currentTime = sound._start || 0; sound._node.pause(); } } - } - if (sound && !internal) { - self._emit('stop', sound._id); + if (!internal) { + self._emit('stop', sound._id); + } } }