-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
228 lines (203 loc) · 9.57 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>OliXMusic</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<header>
<div class="header-container">
<h1>OliXMusic</h1>
</div>
</header>
<main>
<!-- Add the search input field -->
<input type="text" id="searchInput" oninput="searchSongs()" placeholder="Search for a song">
<div class="song-container">
<div class="song-list" id="songList"></div>
</div>
<div class="audio-container">
<audio controls id="audioPlayer" onplay="updateNowPlaying()" onended="playNext()">
Your browser does not support the audio element.
</audio>
<button class="shuffle-button" onclick="toggleShuffle()">Shuffle</button>
<button class="loop-button" onclick="toggleLoop()">Loop</button>
<button class="previous-button" onclick="playPrevious()">Previous</button>
<button class="next-button" onclick="playNext()">Next</button>
</div>
<div class="now-playing" id="nowPlaying">
<strong>Now Playing:</strong> <span id="currentSong">Nothing</span>
</div>
</main>
<script>
// Sample song data with images
const songs = [
{ title: 'Godzilla (feat. Juice WRLD)', artist: 'Eminem, Juice WRLD', image: 'EminemGodzilla.png', source: 'EminemGodzilla.mp3' },
{ title: 'Lovin On Me', artist: 'Jack Harlow', image: 'LovinOnMe.png', source: 'LovinOnMe.mp3' },
{ title: 'Wat U Want 2 (prod. SKY)', artist: 'Yeat', image: 'WatUWant2.png', source: 'WatUWant2.mp3' },
{ title: 'sdp interlude (Extended)', artist: 'Travis Scott', image: 'sdpinterlude(Extended).png', source: 'sdpinterlude(Extended).mp3' },
{ title: 'ICEWHORE!', artist: 'Lumi Athena', image: 'ICEWHORE!.png', source: 'ICEWHORE!.mp3' },
{ title: 'Skyfall', artist: 'Adele', image: 'Skyfall.png', source: 'Skyfall.mp3' },
{ title: 'Goofy Music', artist: 'Aaron, Mantas', image: 'goofymusic.png', source: 'goofymusic.mp3' },
{ title: 'The Real Slim Shady', artist: 'Eminem', image: 'TheRealSlimShady.png', source: 'TheRealSlimShady.mp3' },
{ title: 'goosebumps', artist: 'Travis Scott', image: 'sdpinterlude(Extended).png', source: 'goosebumps.mp3' },
{ title: 'bando', artist: 'Playboi Carti', image: 'bando.png', source: 'bando.mp3' },
{ title: 'listen!', artist: 'hako', image: 'listen!.png', source: 'listen!.mp3' },
{ title: 'fukumean', artist: 'Gunna', image: 'fukumean.png', source: 'fukumean.mp3' },
{ title: 'Swimming Pools', artist: 'Kendrick Lamar', image: 'SwimmingPools.png', source: 'SwimmingPools.mp3' },
{ title: 'SICKO MODE', artist: 'Travis Scott', image: 'SICKOMODE.png', source: 'SICKOMODE.mp3' },
{ title: 'Love Sosa', artist: 'Chief Keef', image: 'LoveSosa.png', source: 'LoveSosa.mp3' },
{ title: 'I Was Never There', artist: 'The Weeknd, Gesaffelstein', image: 'IWasNeverThere.png', source: 'IWasNeverThere.mp3' },
{ title: 'Popular', artist: 'The Weeknd, Playboi Carti, Madonna', image: 'Popular.png', source: 'Popular.mp3' },
{ title: 'goosebumps (BRAINROT)', artist: 'Spidermaneditz', image: 'goosebumps(BRAINROT).png', source: 'goosebumps(BRAINROT).mp3' },
{ title: 'OUT WEST (feat. Young Thug)', artist: 'JACKBOYS, Travis Scott, Young Thug', image: 'OUTWEST.png', source: 'OUTWEST.mp3' },
{ title: 'FE!N', artist: 'Travis Scott, Playboi Carti', image: 'FE!N.png', source: 'FE!N.mp3' },
{ title: 'CARNIVAL', artist: '¥$, Ye, Ty Dolla $ign ft. Playboi Carti & Rich The Kid', image: 'CARNIVAL.png', source: 'CARNIVAL.mp3' },// Add more songs as needed
];
const songList = document.getElementById('songList');
const audioPlayer = document.getElementById('audioPlayer');
const nowPlaying = document.getElementById('nowPlaying');
const currentSong = document.getElementById('currentSong');
const shuffleButton = document.querySelector('.shuffle-button');
const loopButton = document.querySelector('.loop-button');
const previousButton = document.querySelector('.previous-button');
const nextButton = document.querySelector('.next-button');
let currentSongIndex = 0;
let isShuffleMode = false;
let isLoopMode = false;
let shuffledIndexes = [];
// Function to display a list of songs
function displaySongs() {
songs.forEach((song, index) => {
const songItem = document.createElement('div');
songItem.classList.add('song-item');
songItem.innerHTML = `
<div class="song-info">
<div class="song-image-container">
<img src="${song.image}" alt="${song.title} Cover" class="song-image">
<button class="play-button" onclick="playSong(${index})">▶</button>
</div>
<div class="song-details">
<span class="song-title">${song.title}</span>
<span class="song-artist">${song.artist}</span>
</div>
</div>`;
songList.appendChild(songItem);
});
}
// Function to play a specific song
function playSong(index) {
currentSongIndex = index;
audioPlayer.src = songs[currentSongIndex].source;
audioPlayer.play();
updateNowPlaying();
}
// Function to update the Now Playing section
function updateNowPlaying() {
const currentSongTitle = audioPlayer.src ? getCurrentSongTitle() : 'Nothing';
currentSong.textContent = currentSongTitle;
}
// Function to get the title of the currently playing song
function getCurrentSongTitle() {
const currentSource = audioPlayer.src;
for (const song of songs) {
if (currentSource.includes(song.source)) {
return `${song.title} - ${song.artist}`;
}
}
return 'Nothing';
}
// Function to play the next song
function playNext() {
if (isShuffleMode) {
playShuffledNext();
} else {
currentSongIndex = (currentSongIndex + 1) % songs.length;
}
playSong(currentSongIndex);
}
// Function to play the previous song
function playPrevious() {
if (isShuffleMode) {
playShuffledPrevious();
} else {
currentSongIndex = (currentSongIndex - 1 + songs.length) % songs.length;
}
playSong(currentSongIndex);
}
// Function to shuffle the songs
function shuffleSongs() {
const tempIndexes = Array.from({ length: songs.length }, (_, index) => index);
shuffledIndexes = [];
while (tempIndexes.length > 0) {
const randomIndex = Math.floor(Math.random() * tempIndexes.length);
const removedIndex = tempIndexes.splice(randomIndex, 1)[0];
// Avoid shuffling the same song that just ended
if (removedIndex !== currentSongIndex) {
shuffledIndexes.push(removedIndex);
}
}
}
// Function to play the next song in shuffle mode
function playShuffledNext() {
if (shuffledIndexes.length === 0) {
shuffleSongs();
}
currentSongIndex = shuffledIndexes.shift();
playSong(currentSongIndex);
}
// Function to play the previous song in shuffle mode
function playShuffledPrevious() {
if (shuffledIndexes.length === 0) {
shuffleSongs();
}
currentSongIndex = shuffledIndexes.pop();
playSong(currentSongIndex);
}
// Function to toggle shuffle mode
function toggleShuffle() {
isShuffleMode = !isShuffleMode;
shuffleButton.classList.toggle('active', isShuffleMode);
if (isShuffleMode) {
shuffleSongs();
}
}
// Function to toggle loop mode
function toggleLoop() {
isLoopMode = !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();
const filteredSongs = songs.filter(song =>
song.title.toLowerCase().includes(searchInput) || song.artist.toLowerCase().includes(searchInput)
);
// Clear existing songs
songList.innerHTML = '';
// Display the filtered songs
filteredSongs.forEach((song, index) => {
const songItem = document.createElement('div');
songItem.classList.add('song-item');
songItem.innerHTML = `
<div class="song-info">
<div class="song-image-container">
<img src="${song.image}" alt="${song.title} Cover" class="song-image">
<button class="play-button" onclick="playSong(${index})">▶</button>
</div>
<div class="song-details">
<span class="song-title">${song.title}</span>
<span class="song-artist">${song.artist}</span>
</div>
</div>`;
songList.appendChild(songItem);
});
}
// Initial display of songs
displaySongs();
</script>
</body>
</html>