Spaces:
Running
Running
Commit
·
9bc84ae
1
Parent(s):
18feb2d
Update audio.js
Browse files
audio.js
CHANGED
@@ -2,30 +2,32 @@ document.addEventListener('DOMContentLoaded', function () {
|
|
2 |
const searchBar = document.getElementById('searchBar');
|
3 |
const songNames = document.querySelectorAll('h1[style="font-size: 28px;"]');
|
4 |
const descriptions = document.querySelectorAll('p[style="font-size: 20px;"]');
|
5 |
-
|
6 |
|
7 |
-
|
8 |
-
|
9 |
const audio = this.querySelector('audio');
|
10 |
|
11 |
-
//
|
12 |
songContainers.forEach(function (otherContainer) {
|
13 |
const otherAudio = otherContainer.querySelector('audio');
|
14 |
if (otherAudio !== audio && !otherAudio.paused) {
|
15 |
otherAudio.pause();
|
16 |
-
otherAudio.
|
17 |
}
|
18 |
});
|
19 |
|
20 |
-
audio
|
21 |
-
|
22 |
-
if (audio.paused) {
|
23 |
-
audio.play();
|
24 |
-
} else {
|
25 |
audio.pause();
|
|
|
|
|
|
|
|
|
26 |
}
|
27 |
});
|
28 |
});
|
|
|
29 |
searchBar.addEventListener('input', function() {
|
30 |
const searchText = searchBar.value.toLowerCase();
|
31 |
|
|
|
2 |
const searchBar = document.getElementById('searchBar');
|
3 |
const songNames = document.querySelectorAll('h1[style="font-size: 28px;"]');
|
4 |
const descriptions = document.querySelectorAll('p[style="font-size: 20px;"]');
|
5 |
+
const songContainers = document.querySelectorAll('.movie');
|
6 |
|
7 |
+
songContainers.forEach(function (container) {
|
8 |
+
container.addEventListener('click', function () {
|
9 |
const audio = this.querySelector('audio');
|
10 |
|
11 |
+
// Hide all other audio elements except the one clicked
|
12 |
songContainers.forEach(function (otherContainer) {
|
13 |
const otherAudio = otherContainer.querySelector('audio');
|
14 |
if (otherAudio !== audio && !otherAudio.paused) {
|
15 |
otherAudio.pause();
|
16 |
+
otherAudio.style.display = 'none'; // Hide other audio elements
|
17 |
}
|
18 |
});
|
19 |
|
20 |
+
// Toggle the display of the audio element
|
21 |
+
if (audio.style.display === 'block') {
|
|
|
|
|
|
|
22 |
audio.pause();
|
23 |
+
audio.style.display = 'none';
|
24 |
+
} else {
|
25 |
+
audio.style.display = 'block';
|
26 |
+
audio.play();
|
27 |
}
|
28 |
});
|
29 |
});
|
30 |
+
|
31 |
searchBar.addEventListener('input', function() {
|
32 |
const searchText = searchBar.value.toLowerCase();
|
33 |
|