riddhiman commited on
Commit
9b0ef7c
·
verified ·
1 Parent(s): a3de571

Update public/script.js

Browse files
Files changed (1) hide show
  1. public/script.js +5 -5
public/script.js CHANGED
@@ -13,7 +13,7 @@ function toggleLoop() {
13
  isLooping = !isLooping;
14
  document.getElementById('loop-toggle').textContent = `Loop: ${isLooping ? 'On' : 'Off'}`;
15
  const player = document.getElementById('audio-player');
16
- player.loop = isLooping; // Adjust the loop attribute of the audio player
17
  }
18
 
19
  function loadMusicList() {
@@ -24,7 +24,7 @@ function loadMusicList() {
24
  .then(tracks => {
25
  const musicList = document.getElementById('music-list');
26
  musicList.innerHTML = '';
27
- trackList = []; // Reset track list for new fetch
28
 
29
  tracks.forEach(track => {
30
  if (track.filename.toLowerCase().includes(searchQuery)) {
@@ -64,7 +64,7 @@ function playMusic(fileName) {
64
  const player = document.getElementById('audio-player');
65
 
66
  const existingLoader = document.querySelector('.loader-container');
67
- existingLoader && existingLoader.remove(); // Remove any existing loader
68
 
69
  const loaderContainer = document.createElement('div');
70
  loaderContainer.classList.add('loader-container');
@@ -82,7 +82,7 @@ function playMusic(fileName) {
82
  loaderContainer.remove();
83
  player.style.display = '';
84
  player.play();
85
- player.loop = isLooping; // Ensure loop state is correct
86
  };
87
 
88
  player.onended = () => {
@@ -91,7 +91,7 @@ function playMusic(fileName) {
91
  if (currentIndex !== -1 && currentIndex < trackList.length - 1) {
92
  playMusic(trackList[currentIndex + 1]);
93
  } else {
94
- // Optional: Handle scenario when the playlist ends / Repeat playlist
95
  }
96
  }
97
  };
 
13
  isLooping = !isLooping;
14
  document.getElementById('loop-toggle').textContent = `Loop: ${isLooping ? 'On' : 'Off'}`;
15
  const player = document.getElementById('audio-player');
16
+ player.loop = isLooping;
17
  }
18
 
19
  function loadMusicList() {
 
24
  .then(tracks => {
25
  const musicList = document.getElementById('music-list');
26
  musicList.innerHTML = '';
27
+ trackList = [];
28
 
29
  tracks.forEach(track => {
30
  if (track.filename.toLowerCase().includes(searchQuery)) {
 
64
  const player = document.getElementById('audio-player');
65
 
66
  const existingLoader = document.querySelector('.loader-container');
67
+ existingLoader && existingLoader.remove();
68
 
69
  const loaderContainer = document.createElement('div');
70
  loaderContainer.classList.add('loader-container');
 
82
  loaderContainer.remove();
83
  player.style.display = '';
84
  player.play();
85
+ player.loop = isLooping;
86
  };
87
 
88
  player.onended = () => {
 
91
  if (currentIndex !== -1 && currentIndex < trackList.length - 1) {
92
  playMusic(trackList[currentIndex + 1]);
93
  } else {
94
+ // Handle scenario when the playlist ends / Repeat playlist
95
  }
96
  }
97
  };