Spaces:
Running
Running
JAYASWAROOP
commited on
Commit
•
2f8c35e
1
Parent(s):
c2d8f69
Update audio.js
Browse files
audio.js
CHANGED
@@ -1,21 +1,23 @@
|
|
1 |
-
document
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
|
7 |
-
|
8 |
-
|
|
|
|
|
9 |
|
10 |
-
|
11 |
-
|
12 |
-
const description = descriptions[index].textContent.toLowerCase();
|
13 |
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
}
|
20 |
-
|
21 |
});
|
|
|
|
|
|
1 |
+
// Wait for the document to load
|
2 |
+
document.addEventListener('DOMContentLoaded', function () {
|
3 |
+
// Get all the song containers
|
4 |
+
const songContainers = document.querySelectorAll('.movie');
|
|
|
5 |
|
6 |
+
// Attach a click event listener to each song container
|
7 |
+
songContainers.forEach(function (container) {
|
8 |
+
container.addEventListener('click', function () {
|
9 |
+
const audio = this.querySelector('audio'); // Get the audio element inside the container
|
10 |
|
11 |
+
// Toggle the visibility of the audio element
|
12 |
+
audio.classList.toggle('d-none');
|
|
|
13 |
|
14 |
+
// Check if the audio is playing or paused, and toggle play/pause accordingly
|
15 |
+
if (audio.paused) {
|
16 |
+
audio.play(); // Play the audio if it's paused
|
17 |
+
} else {
|
18 |
+
audio.pause(); // Pause the audio if it's playing
|
19 |
+
}
|
20 |
+
});
|
21 |
});
|
22 |
+
});
|
23 |
+
|