// Function to play a specific song
function playSong(index) {
- // Find the index in the original list based on the filtered list
- const originalIndex = songs.findIndex(song => song === filteredSongs[index]);
-
- // Set the current song index and play the song
- currentSongIndex = originalIndex;
+ currentSongIndex = index;
audioPlayer.src = songs[currentSongIndex].source;
audioPlayer.play();
updateNowPlaying();
@@ -183,24 +181,41 @@
OliXMusic
// Function to toggle loop mode
function toggleLoop() {
isLoopMode = !isLoopMode;
- audioPlayer.loop = isLoopMode;
loopButton.classList.toggle('active', isLoopMode);
+ audioPlayer.loop = isLoopMode;
}
// Function to filter and display songs based on the search query
function searchSongs() {
const searchInput = document.getElementById('searchInput').value.toLowerCase();
- filteredSongs = songs.filter(song =>
+ const filteredSongs = songs.filter(song =>
song.title.toLowerCase().includes(searchInput) || song.artist.toLowerCase().includes(searchInput)
);
+ // Clear existing songs
+ songList.innerHTML = '';
+
// Display the filtered songs
- displaySongs(filteredSongs);
+ filteredSongs.forEach((song, index) => {
+ const songItem = document.createElement('div');
+ songItem.classList.add('song-item');
+ songItem.innerHTML = `
+