JAYASWAROOP commited on
Commit
a07f405
1 Parent(s): de7f03e

Update audio.js

Browse files
Files changed (1) hide show
  1. audio.js +5 -3
audio.js CHANGED
@@ -5,7 +5,7 @@ document.addEventListener('DOMContentLoaded', function () {
5
  container.addEventListener('click', function () {
6
  const audio = this.querySelector('audio');
7
 
8
- // Hide all other audio elements except the one clicked
9
  movieContainers.forEach(function (otherContainer) {
10
  const otherAudio = otherContainer.querySelector('audio');
11
  if (otherAudio !== audio && !otherAudio.paused) {
@@ -14,13 +14,15 @@ document.addEventListener('DOMContentLoaded', function () {
14
  }
15
  });
16
 
17
- // Toggle the display class of the audio element
18
- audio.classList.toggle('d-none');
19
  if (audio.paused) {
20
  audio.play();
21
  } else {
22
  audio.pause();
23
  }
 
 
 
24
  });
25
  });
26
  });
 
5
  container.addEventListener('click', function () {
6
  const audio = this.querySelector('audio');
7
 
8
+ // Pause all other audio elements except the one clicked
9
  movieContainers.forEach(function (otherContainer) {
10
  const otherAudio = otherContainer.querySelector('audio');
11
  if (otherAudio !== audio && !otherAudio.paused) {
 
14
  }
15
  });
16
 
17
+ // If audio is paused or not already playing, play it
 
18
  if (audio.paused) {
19
  audio.play();
20
  } else {
21
  audio.pause();
22
  }
23
+
24
+ // Toggle the display of the audio element
25
+ audio.classList.toggle('d-none');
26
  });
27
  });
28
  });