Spaces:
Runtime error
Runtime error
Update public/script.js
Browse files- public/script.js +13 -0
public/script.js
CHANGED
|
@@ -31,6 +31,7 @@ function loadMusicList() {
|
|
| 31 |
trackList.push(track.filename); // Populate trackList
|
| 32 |
const musicItem = document.createElement('div');
|
| 33 |
musicItem.classList.add('music-item');
|
|
|
|
| 34 |
|
| 35 |
const playButton = document.createElement('button');
|
| 36 |
playButton.innerHTML = '▶';
|
|
@@ -52,6 +53,17 @@ function loadMusicList() {
|
|
| 52 |
});
|
| 53 |
}
|
| 54 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
function playMusic(fileName) {
|
| 56 |
if (isLoadingMusic || fileName === currentPlaying) {
|
| 57 |
console.log("This song is already loading or playing.");
|
|
@@ -60,6 +72,7 @@ function playMusic(fileName) {
|
|
| 60 |
|
| 61 |
isLoadingMusic = true;
|
| 62 |
currentPlaying = fileName;
|
|
|
|
| 63 |
|
| 64 |
const player = document.getElementById('audio-player');
|
| 65 |
|
|
|
|
| 31 |
trackList.push(track.filename); // Populate trackList
|
| 32 |
const musicItem = document.createElement('div');
|
| 33 |
musicItem.classList.add('music-item');
|
| 34 |
+
musicItem.setAttribute('data-filename', track.filename); // Add this line
|
| 35 |
|
| 36 |
const playButton = document.createElement('button');
|
| 37 |
playButton.innerHTML = '▶';
|
|
|
|
| 53 |
});
|
| 54 |
}
|
| 55 |
|
| 56 |
+
function updatePlayingIndicator() {
|
| 57 |
+
const musicItems = document.querySelectorAll('.music-item');
|
| 58 |
+
musicItems.forEach(item => {
|
| 59 |
+
if (item.getAttribute('data-filename') === currentPlaying) {
|
| 60 |
+
item.style.boxShadow = '0 0 15px #00ff00'; // Green box shadow
|
| 61 |
+
} else {
|
| 62 |
+
item.style.boxShadow = ''; // Remove box shadow from other items
|
| 63 |
+
}
|
| 64 |
+
});
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
function playMusic(fileName) {
|
| 68 |
if (isLoadingMusic || fileName === currentPlaying) {
|
| 69 |
console.log("This song is already loading or playing.");
|
|
|
|
| 72 |
|
| 73 |
isLoadingMusic = true;
|
| 74 |
currentPlaying = fileName;
|
| 75 |
+
updatePlayingIndicator();
|
| 76 |
|
| 77 |
const player = document.getElementById('audio-player');
|
| 78 |
|