From bad48e0e15d0cadf3dc24a4d00b2197bc1ee1b8f Mon Sep 17 00:00:00 2001 From: Fen Dweller Date: Sat, 5 Jan 2019 17:34:30 -0600 Subject: [PATCH] Added functions to stop all sounds --- audio.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/audio.js b/audio.js index 37acc93..1736666 100644 --- a/audio.js +++ b/audio.js @@ -59,6 +59,11 @@ function stopSfx(name) { cleanPlaying(); } +function stopAllSfx() { + playing.map(item => item.stop()); + cleanPlaying(); +} + function stopLoop(name) { if (looping[name]) { looping[name].stop(); @@ -66,6 +71,18 @@ function stopLoop(name) { } } +function stopAllLoops() { + Object.entries(looping).forEach(([key, val]) => { + val.stop(); + delete looping[key]; + }); +} + +function stopAllSound() { + stopAllSfx(); + stopAllLoops(); +} + function cleanPlaying() { playing = playing.filter(item => !item.done); }