From 707a5708284e972488d0435801a8a5e8a56c98c2 Mon Sep 17 00:00:00 2001 From: simon987 Date: Sat, 17 Apr 2021 13:24:21 -0400 Subject: [PATCH] Pause all other audio tags on play #148 --- src/static/js/dom.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/static/js/dom.js b/src/static/js/dom.js index 6ccbf45..2bb3f25 100644 --- a/src/static/js/dom.js +++ b/src/static/js/dom.js @@ -350,6 +350,14 @@ function createDocCard(hit) { audio.setAttribute("controls", ""); audio.setAttribute("type", hit["_source"]["mime"]); audio.setAttribute("src", "f/" + hit["_id"]); + audio.addEventListener("play", () => { + // Pause all currently playing audio tags + $("audio").each(function(){ + if (this !== audio) { + this.pause(); + } + }); + }); docCard.appendChild(audio) }