JAYASWAROOP commited on
Commit
2f8c35e
1 Parent(s): c2d8f69

Update audio.js

Browse files
Files changed (1) hide show
  1. audio.js +19 -17
audio.js CHANGED
@@ -1,21 +1,23 @@
1
- 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
- searchBar.addEventListener('input', function() {
8
- const searchText = searchBar.value.toLowerCase();
 
 
9
 
10
- songNames.forEach((song, index) => {
11
- const songName = song.textContent.toLowerCase();
12
- const description = descriptions[index].textContent.toLowerCase();
13
 
14
- if (songName.includes(searchText) || description.includes(searchText)) {
15
- song.parentElement.parentElement.style.display = 'block';
16
- } else {
17
- song.parentElement.parentElement.style.display = 'none';
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
+