From 1044619c9bfb59c756ae6c5cc871ace7a387be82 Mon Sep 17 00:00:00 2001 From: Jeremy Dixon Date: Fri, 22 Jan 2021 16:29:59 -0600 Subject: [PATCH] add sound interruption --- script_background.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/script_background.js b/script_background.js index e473ffb..97c3498 100644 --- a/script_background.js +++ b/script_background.js @@ -5,6 +5,7 @@ let time=1000; let timer = setInterval(()=>{ if(started){time++} },1000); +let currSound; chrome.runtime.onMessage.addListener((request, sender, sendResponse)=>{ console.log(request); @@ -65,7 +66,9 @@ let alert_manager = { console.log('Playing Alert') alert = new Audio(chrome.runtime.getURL(`./assets/sounds/${alertFile}.mp3`)); alert.volume = (1/5)*options["volume"]; - alert.play(); + if(currSound){currSound.pause()} + currSound = alert; + currSound.play(); started = true; time = 0; }