-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
483 lines (412 loc) · 20 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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Music Player</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Open+Sans:wght@300;400;500&display=swap" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
<style type="text/css">
body, html {
margin: 0px;
padding: 0px;
width: 100%;
background-color: #f5f5f5;
font-family: 'Open Sans', sans-serif;
}
* {
box-sizing: border-box;
}
.card {
margin: 150px auto;
max-width: 470px;
background-color: #fff;
-webkit-box-shadow: 0px 0px 15px 11px rgba(1,191,165,0.11);
box-shadow: 0px 0px 15px 11px rgba(1,191,165,0.11);
}
.topInfo {
display: flex;
padding: 30px;
}
.topInfo div:first-of-type {
max-width: 50px;
}
.topInfo div:nth-of-type(3) {
max-width: 50px;
text-align: right;
}
.topInfo div:nth-of-type(2) {
flex-grow: 1;
text-align: center;
padding-top: 10px;
line-height: 26px;
}
.topInfo .item + .item {
margin-left: 2%;
}
small {
color: #899da7;
font-size: 14px;
}
.cover {
display: block;
margin: auto;
-webkit-box-shadow: 0px 0px 37px 18px rgba(182,182,182,0.63);
box-shadow: 0px 0px 37px 18px rgba(182,182,182,0.63);
margin-bottom: 23px;
transition: transform .7s;
width: 236px;
height: 236px;
}
.cover:hover {
-ms-transform: scale(1.1); /* IE 9 */
-webkit-transform: scale(1.1); /* Safari 3-8 */
transform: scale(1.1);
cursor: pointer;
}
progress {
border: 0px;
border-radius: 10px;
height: 5px;
color: #01bfa5;
}
progress::-moz-progress-bar { background: #01bfa5; border: 0px; }
progress::-webkit-progress-value { background: #01bfa5; }
.playTime {
width: 85%;
margin: auto;
font-size: 14px;
color: #666;
margin-top: 2px;
}
.playTime span:last-of-type {
display: block;
float: right;
}
.controls {
display: flex;
width: 75%;
margin: auto;
justify-content: space-evenly;
align-items: center;
flex-wrap: wrap;
gap: 5px;
}
svg:hover {
stroke: #01bfa5;
}
.controls > div {
padding: 8px;
}
svg {
cursor: pointer;
}
.shuffleOn {
stroke: #01bfa5;
}
.repeatOn {
stroke: #01bfa5;
}
.playNow {
background-image: url("data:image/svg+xml,%3Csvg fill='%23000000' height='56px' width='56px' version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' viewBox='0 0 60 60' xml:space='preserve'%3E%3Cg%3E%3Cpath d='M45.563 29.174l-22-15c-0.307-0.208-0.703-0.231-1.031-0.058C22.205 14.289 22 14.629 22 15v30 c0 0.371 0.205 0.711 0.533 0.884C22.679 45.962 22.84 46 23 46c0.197 0 0.394-0.059 0.563-0.174l22-15 C45.836 30.64 46 30.331 46 30S45.836 29.36 45.563 29.174z M24 43.107V16.893L43.225 30L24 43.107z'/%3E%3Cpath d='M30 0C13.458 0 0 13.458 0 30s13.458 30 30 30s30-13.458 30-30S46.542 0 30 0z M30 58C14.561 58 2 45.439 2 30 S14.561 2 30 2s28 12.561 28 28S45.439 58 30 58z'/%3E%3C/g%3E%3C/svg%3E ");
width: 56px;
height: 56px;
cursor: pointer;
}
.playNow:hover {
background-image: url("data:image/svg+xml,%3Csvg fill='%2301bfa5' height='56px' width='56px' version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' viewBox='0 0 60 60' xml:space='preserve'%3E%3Cg%3E%3Cpath d='M45.563 29.174l-22-15c-0.307-0.208-0.703-0.231-1.031-0.058C22.205 14.289 22 14.629 22 15v30 c0 0.371 0.205 0.711 0.533 0.884C22.679 45.962 22.84 46 23 46c0.197 0 0.394-0.059 0.563-0.174l22-15 C45.836 30.64 46 30.331 46 30S45.836 29.36 45.563 29.174z M24 43.107V16.893L43.225 30L24 43.107z'/%3E%3Cpath d='M30 0C13.458 0 0 13.458 0 30s13.458 30 30 30s30-13.458 30-30S46.542 0 30 0z M30 58C14.561 58 2 45.439 2 30 S14.561 2 30 2s28 12.561 28 28S45.439 58 30 58z'/%3E%3C/g%3E%3C/svg%3E ");
}
.pauseNow {
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='56' viewBox='0 0 24 24' stroke-width='1' stroke='%2301bfa5' fill='none' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath stroke='none' d='M0 0h24v24H0z' fill='none'/%3E%3Crect x='6' y='5' width='4' height='14' rx='1' /%3E%3Crect x='14' y='5' width='4' height='14' rx='1' /%3E%3C/svg%3E");
width: 56px;
height: 56px;
cursor: pointer;
}
.playlistRow {
display: flex;
width: auto;
margin: auto;
padding: 15px 36px;
background-color: white;
transition: background-color 0.3s ease;
transition: color 0.3s;
cursor: pointer;
font-weight: 300;
}
.playlistRow:hover {
background-color: #01bfa5;
color: white;
transition: background-color 0.3s ease;
}
.playlistRow:hover .dot {
color: white;
}
.playlistRow div:nth-last-of-type() {
width: 70px;
}
.playlistRow div:first-of-type {
flex-grow: 1;
}
.playlistRow .div + .div {
margin-left: 2%;
}
.playlistRow.nowPlaying {
font-weight: 500;
background-color: #deefed;
}
.dot {
display: inline-block;
position: absolute;
color: #00c0a5;
margin-left: -20px;
font-size: 36px;
line-height: 22px;
}
</style>
</head>
<body>
<div class="card">
<div class="topInfo">
<div>
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-menu-2" width="36" height="36" viewBox="0 0 24 24" stroke-width="1.5" stroke="#465a63" fill="none" stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z" fill="none"/>
<line x1="4" y1="6" x2="20" y2="6" />
<line x1="4" y1="12" x2="20" y2="12" />
<line x1="4" y1="18" x2="20" y2="18" />
</svg>
</div>
<div>
<small>NOW PLAYING</small><br>
<span style="font-size: 18px;" id="songTitle">Someone Lived This</span><br>
<small id="artist">- Alex MakeMusic -</small>
</div>
<div>
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-playlist" width="36" height="36" viewBox="0 0 24 24" stroke-width="1.5" stroke="#465a63" fill="none" stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z" fill="none"/>
<circle cx="14" cy="17" r="3" />
<path d="M17 17v-13h4" />
<path d="M13 5h-10" />
<line x1="3" y1="9" x2="13" y2="9" />
<path d="M9 13h-6" />
</svg>
</div>
</div>
<img src="https://cdn.pixabay.com/audio/2022/08/04/08-56-45-239_200x200.jpg" class="cover">
<br>
<progress id="seekbar" value="0" max="1" value="0" style="width: 85%; margin:auto; display: block;"></progress>
<div class="playTime">
<span> </span>
<span> </span>
</div>
<br>
<div class="controls">
<div>
<svg id="repeat" onclick="repeatSongs()" data-value="0" xmlns="http://www.w3.org/2000/svg" width="36" height="36" viewBox="0 0 24 24" stroke-width="1" stroke="#465a63" fill="none" stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z" fill="none"/>
<path d="M4 12v-3a3 3 0 0 1 3 -3h13m-3 -3l3 3l-3 3" />
<path d="M20 12v3a3 3 0 0 1 -3 3h-13m3 3l-3 -3l3 -3" />
</svg>
</div>
<div>
<svg id="pre" onclick="pre()" xmlns="http://www.w3.org/2000/svg" width="36" height="36" viewBox="0 0 24 24" stroke-width="1" stroke="#465a63" fill="none" stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z" fill="none"/>
<path d="M20 5v14l-12 -7z" />
<line x1="4" y1="5" x2="4" y2="19" />
</svg>
</div>
<div>
<div class="playNow" id='play' onclick='playOrPauseSong()'></div>
</div>
<div>
<svg id="next" onclick="next()" xmlns="http://www.w3.org/2000/svg" width="36" height="36" viewBox="0 0 24 24" stroke-width="1" stroke="#465a63" fill="none" stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z" fill="none"/>
<path d="M4 5v14l12 -7z" />
<line x1="20" y1="5" x2="20" y2="19" />
</svg>
</div>
<div>
<svg id="shuffle" onclick="shuffleToggle()" data-value="0" fill="#465a63" height="32px" width="32px" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 49.7 49.7" xml:space="preserve">
<g id="SVGRepo_bgCarrier" stroke-width="0"/>
<g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round" stroke="#CCCCCC" stroke-width="0.09940000000000002"/>
<g id="SVGRepo_iconCarrier"> <g> <path d="M27,13.85h9v8.964l13.7-9.964L36,2.886v8.964h-9c-7.168,0-13,5.832-13,13c0,6.065-4.935,11-11,11H1c-0.553,0-1,0.447-1,1 s0.447,1,1,1h2c7.168,0,13-5.832,13-13C16,18.785,20.935,13.85,27,13.85z M38,6.814l8.3,6.036L38,18.886V6.814z"/> <path d="M1,13.85h2c2.713,0,5.318,0.994,7.336,2.799c0.191,0.171,0.43,0.255,0.667,0.255c0.274,0,0.548-0.112,0.745-0.333 c0.368-0.412,0.333-1.044-0.078-1.412C9.285,13.025,6.206,11.85,3,11.85H1c-0.553,0-1,0.447-1,1S0.447,13.85,1,13.85z"/> <path d="M36,35.85h-9c-2.685,0-5.27-0.976-7.278-2.748c-0.411-0.365-1.044-0.327-1.411,0.089c-0.365,0.414-0.326,1.046,0.089,1.411 c2.374,2.095,5.429,3.248,8.601,3.248h9v8.964l13.7-9.964L36,26.886V35.85z M38,30.814l8.3,6.036L38,42.886V30.814z"/> </g> </g>
</svg>
</div>
</div>
<br>
<div class="playlistRow" onclick="playFromPlaylist(0)">
<div><div class="dot">•</div>Down Town</div>
<div class="totalTime">1:13</div>
</div>
<div class="playlistRow" onclick="playFromPlaylist(1)">
<div><div class="dot">•</div>Summer Nights</div>
<div class="totalTime">02:40</div>
</div>
<div class="playlistRow" onclick="playFromPlaylist(2)">
<div><div class="dot">•</div>Broke Me</div>
<div class="totalTime">03:22</div>
</div>
<div class="playlistRow" onclick="playFromPlaylist(3)">
<div><div class="dot">•</div>Future Bass</div>
<div class="totalTime">02:19</div>
</div>
<br>
<div style="text-align: center;"><a href="https://www.twitter.com/neluttu" style="text-decoration: none; color: #01bfa5;">@neluttu</a></div>
<script type="text/javascript">
$('.dot').hide();
var songs = ["https://cdn.pixabay.com/download/audio/2022/01/28/audio_be2ba160f8.mp3?filename=eastern-trap-groove-15883.mp3",
"https://cdn.pixabay.com/download/audio/2022/10/02/audio_c216ad4a20.mp3?filename=summer-nights-tropical-house-music-121570.mp3",
"https://cdn.pixabay.com/download/audio/2022/07/17/audio_e14ca08421.mp3?filename=broke-me-115146.mp3",
// "https://cdn.pixabay.com/download/audio/2023/01/21/audio_4c7b1cd97b.mp3?filename=unexplained-mystery-introoutro-136159.mp3"
"https://cdn.pixabay.com/download/audio/2022/05/17/audio_fbc5d63bc7.mp3?filename=future-bass-hot-night-111447.mp3"
];
var poster = ["https://cdn.pixabay.com/audio/2022/08/04/08-56-45-239_200x200.jpg",
"https://cdn.pixabay.com/audio/2022/10/02/09-06-35-178_200x200.jpg",
"https://cdn.pixabay.com/audio/2022/07/17/14-41-14-378_200x200.jpg",
"https://cdn.pixabay.com/audio/2022/05/17/20-35-00-870_200x200.jpg"];
var artist = ["Alex MakeMusic",
"Music Unlimited",
"FASSounds",
"AlexGrohl"
];
var titles = ["Down Town",
"Summer Nights",
"Broke Me",
"Future Bass"];
var songTitle = document.getElementById("songTitle");
var artistName = document.getElementById("artist");
var fillBar = document.getElementById("fill");
var shuffle = 0;
function shuffleToggle() {
if($('#shuffle').attr('data-value') == 0) {
shuffle = 1;
$('#shuffle').attr('data-value', 1);
$("#shuffle").addClass("shuffleOn");
}
else if($('#shuffle').attr('data-value') == 1) {
shuffle = 0;
$('#shuffle').attr('data-value', 0);
$("#shuffle").removeClass("shuffleOn");
}
console.log(shuffle);
}
var songsRepeat = 0;
function repeatSongs() {
if($('#repeat').attr('data-value') == 0) {
songsRepeat = 1;
$('#repeat').attr('data-value', 1);
$("#repeat").addClass("repeatOn");
}
else if($('#repeat').attr('data-value') == 1) {
songsRepeat = 0;
$('#repeat').attr('data-value', 0);
$("#repeat").removeClass("repeatOn");
}
}
console.log(songsRepeat);
var song = new Audio();
var currentSong = 0;
songTitle.textContent = titles[currentSong];
function playSong() {
song.src = songs[currentSong];
songTitle.textContent = titles[currentSong];
artistName.textContent = artist[currentSong];
$(".cover").attr("src",poster[currentSong]);
$(".playlistRow").removeClass("nowPlaying");
$(".dot").hide(); // hide other nowplaying dots
$(".playlistRow:eq("+currentSong+")").addClass("nowPlaying"); // make now playing bold text
$(".dot:eq("+currentSong+")").show("nowPlaying"); // show now playing dot
song.play();
}
function playFromPlaylist(songg) {
song.src = songs[songg];
songTitle.textContent = titles[songg];
artistName.textContent = artist[songg];
if(song.paused) {
currentSong = songg;
playSong();
$("#play").addClass("pauseNow");
$("#play").removeClass("playNow");
$(".playlistRow").removeClass("nowPlaying");
$(".dot").hide(); // hide other nowplaying dots
$(".playlistRow:eq("+songg+")").addClass("nowPlaying"); // make now playing bold text
$(".dot:eq("+songg+")").show("nowPlaying"); // show now playing dot
$(".cover").attr("src",poster[songg]); // set the poster
}
else {
song.pause();
$("#play").addClass("playNow");
$("#play").removeClass("pauseNow");
}
}
function playOrPauseSong(){
if(song.paused) {
playSong();
$("#play").addClass("pauseNow");
$("#play").removeClass("playNow");
}
else {
song.pause();
$("#play").addClass("playNow");
$("#play").removeClass("pauseNow");
}
}
song.addEventListener('timeupdate',function() {
var showCurrentTime = new Date(this.currentTime * 1000).toISOString().substring(14, 19);
var showTotalTime = new Date(this.duration * 1000).toISOString().substring(14, 19);
$('#seekbar').attr("value", this.currentTime / this.duration);
$('.playTime span:first-of-type').text(showCurrentTime);
$('.playTime span:nth-of-type(2)').text(showTotalTime);
if(this.currentTime == this.duration) {
console.log(Math.floor(Math.random() * songs.length));
currentSong++;
if(shuffle == 1) { currentSong = Math.floor(Math.random() * songs.length); playSong();}
else if(currentSong > songs.length - 1) {
currentSong = 0;
if(songsRepeat == 0) {
$("#play").addClass("playNow");
$("#play").removeClass("pauseNow");
$('.dot').hide();
$(".playlistRow").removeClass("nowPlaying");
return;
}
else playSong();
}
else playSong();
}
});
function next(){
currentSong++;
if(shuffle == 1) currentSong = Math.floor(Math.random() * songs.length);
else if(currentSong > songs.length - 1) currentSong = 0;
playSong();
$("#play").removeClass("playNow");
$("#play").addClass("pauseNow");
$(".playlistRow").removeClass("nowPlaying");
$(".dot").hide(); // hide other nowplaying dots
$(".dot:eq("+currentSong+")").show("nowPlaying"); // show now playing dot
$(".playlistRow:eq("+currentSong+")").addClass("nowPlaying"); // make now playing bold text
$(".poster").attr("src",poster[currentSong]);
}
function pre(){
currentSong--;
if(currentSong < 0){
currentSong = songs.length - 1;
}
else if(shuffle == 1) currentSong = Math.floor(Math.random() * songs.length);
playSong();
$("#play").removeClass("playNow");
$("#play").addClass("pauseNow");
$(".playlistRow").removeClass("nowPlaying");
$(".dot").hide(); // hide other nowplaying dots
$(".playlistRow:eq("+currentSong+")").addClass("nowPlaying"); // make now playing bold text
$(".dot:eq("+currentSong+")").show("nowPlaying"); // show now playing dot
$(".poster").attr("src",poster[currentSong]);
}
</script>
<br><br>
</div>
</body>
</html>