From f9f66ec70fcef5b50e7086900ce55e347ab314d4 Mon Sep 17 00:00:00 2001 From: JPery Date: Wed, 16 Feb 2022 23:04:16 +0100 Subject: [PATCH] Stopping audio if current sounding button is pressed --- app.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app.js b/app.js index c8795aa..8704dee 100644 --- a/app.js +++ b/app.js @@ -144,7 +144,12 @@ function createButton(text, urlSound, id) { link.onclick = function(evt) { evt.preventDefault(); var target = evt.target || evt.srcElement; // Fix for Firefox - hashAudios[target.id].play(); + if (hashAudios[target.id].paused) + hashAudios[target.id].play(); + else { + hashAudios[target.id].pause(); + hashAudios[target.id].currentTime = 0; + } } return link; }