ikraamkb commited on
Commit
0320f83
·
verified ·
1 Parent(s): db876b1

Update static/application.js

Browse files
Files changed (1) hide show
  1. static/application.js +20 -13
static/application.js CHANGED
@@ -274,19 +274,26 @@ document.addEventListener("DOMContentLoaded", () => {
274
  const audio = new Audio(audioSrc);
275
  audio.play();
276
 
277
- icon.addEventListener("click", () => {
278
- if (audio.muted) {
279
- audio.currentTime = 0;
280
- audio.muted = false;
281
- audio.play();
282
- icon.classList.replace("fa-volume-xmark", "fa-volume-high");
283
- icon.title = "Click to mute";
284
- } else {
285
- audio.muted = true;
286
- icon.classList.replace("fa-volume-high", "fa-volume-xmark");
287
- icon.title = "Click to unmute";
288
- }
289
- });
 
 
 
 
 
 
 
290
 
291
  message.appendChild(icon);
292
  }
 
274
  const audio = new Audio(audioSrc);
275
  audio.play();
276
 
277
+ let isMuted = false;
278
+ let audio = new Audio(audioSrc);
279
+ audio.play();
280
+
281
+ icon.addEventListener("click", () => {
282
+ if (isMuted) {
283
+ // Recreate audio to force replay
284
+ audio = new Audio(audioSrc);
285
+ audio.play();
286
+ isMuted = false;
287
+ icon.classList.replace("fa-volume-xmark", "fa-volume-high");
288
+ icon.title = "Click to mute";
289
+ } else {
290
+ audio.pause();
291
+ isMuted = true;
292
+ icon.classList.replace("fa-volume-high", "fa-volume-xmark");
293
+ icon.title = "Click to unmute";
294
+ }
295
+ });
296
+
297
 
298
  message.appendChild(icon);
299
  }