Skip to content

Commit 3348460

Browse files
committed
added
1 parent 349d79d commit 3348460

File tree

7 files changed

+73
-1
lines changed

7 files changed

+73
-1
lines changed

11_muic-player-clone/image.png

5.33 MB
Loading
2.06 MB
Binary file not shown.
201 KB
Binary file not shown.
300 KB
Binary file not shown.
101 KB
Binary file not shown.
150 KB
Binary file not shown.

11_muic-player-clone/script.js

Lines changed: 73 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,76 @@ let timeDuration = document.getElementById('time-duration');
1111
let currentTime = DocumentFragment.getElementById('current-time');
1212
let totalTime = DocumentFragment.getElementById('total-time');
1313

14-
let volumeSlider = document.getElementById('volume-slider');
14+
let volumeSlider = document.getElementById('volume-slider');
15+
16+
let trackIndex = 0;
17+
let isPlaying = false;
18+
let updateTimer;
19+
20+
let curr_track = document.createElement('audio');
21+
let track_list = [
22+
{
23+
name: "Night Owl",
24+
artist: "Broke For Free",
25+
image: "./image.png",
26+
path: "./music/file_example_MP3_2MG.mp3"
27+
},
28+
{
29+
name: "Random Owl",
30+
artist: "Broke For Free",
31+
image: "Image URL",
32+
path: "./music/sample-6s.mp3"
33+
},
34+
{
35+
name: "MidNight Owl",
36+
artist: "Broke For Free",
37+
image: "Image URL",
38+
path: "../music/sample-9s.mp3"
39+
},
40+
{
41+
name: "Day Owl",
42+
artist: "Broke For Free",
43+
image: "Image URL",
44+
path: "/music/sample-12s.mp3"
45+
},
46+
{
47+
name: "ABCD Owl",
48+
artist: "Broke For Free",
49+
image: "Image URL",
50+
path: "/music/sample-15s.mp3"
51+
},
52+
]
53+
54+
function loadTrack(trackIndex) {
55+
clearInterval(updateTimer);
56+
resetValues();
57+
58+
curr_track.src = track_list[trackIndex].path;
59+
curr_track.load();
60+
61+
trackArt.style.backgroundImage = "url(" + track_list[trackIndex].image + ")";
62+
trackName.textContent = track_list[trackIndex].name;
63+
trackArtist.textContent = track_list[trackIndex].artist;
64+
nowPlaying.textContent = "PLAYING " + (trackIndex + 1) + " OF " + track_list.length;
65+
66+
updateTimer = setInterval(seekUpdate, 1000);
67+
curr_track.addEventListener("ended", nextBtn);
68+
random_bg_color();
69+
}
70+
71+
function resetValues() {
72+
currentTime.textContent = "00.00";
73+
totalTime.textContent = "00.00";
74+
volumeSlider.value = 0;
75+
}
76+
77+
function random_bg_color() {
78+
let red = Math.floor(Math.random() * 256) + 64;
79+
let green = Math.floor(Math.random() * 256) + 64;
80+
let blue = Math.floor(Math.random() * 256) + 64;
81+
82+
let bgColor = "rgb(" + red + ", " + green + ", " + blue + ")";
83+
document.body.style.background = bgColor;
84+
}
85+
86+

0 commit comments

Comments
 (0)