-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
39 lines (33 loc) · 958 Bytes
/
app.js
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
// select let html:
let progress = document.querySelector("#progress")
let song = document.querySelector("#song")
let ctrIcon = document.querySelector("#ctrIcon")
// onloaded function
song.onloadedmetadata = function () {
progress.max = song.duration;
progress.value = song.currentTime;
}
// paly function
function playePuase() {
if (ctrIcon.classList.contains("fa-pause")) {
song.pause();
ctrIcon.classList.remove("fa-pause");
ctrIcon.classList.add("fa-play");
} else {
song.play()
ctrIcon.classList.add("fa-pause");
ctrIcon.classList.remove("fa-play");
}
}
if (song.play()) {
// setTime To drag the music range with the mouse
setInterval(() => {
progress.value = song.currentTime;
}, 600)
}
progress.onchange = function () {
song.play();
song.currentTime = progress.value;
ctrIcon.classList.add("fa-pause");
ctrIcon.classList.remove("fa-play");
}