Skip to content

Commit c584f46

Browse files
committed
added
1 parent 3348460 commit c584f46

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

11_muic-player-clone/script.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,35 @@ function random_bg_color() {
8383
document.body.style.background = bgColor;
8484
}
8585

86+
function playpauseTrack() {
87+
if(!isPlaying) playTrack();
88+
else pauseTrack();
89+
}
90+
function playTrack() {
91+
curr_track.play();
92+
isPlaying = true;
93+
94+
playPauseBtn.innerHTML = '<i class = "fa fa-pause-circle fa-5x"</i>';
95+
}
96+
function pauseTrack() {
97+
curr_track.pause();
98+
isPlaying = false;
99+
100+
playPauseBtn.innerHTML = '<i class = "fa fa-play-circle fa-5x"</i>';
101+
}
102+
function nextBtn() {
103+
if(trackIndex < track_list.length - 1)
104+
trackIndex += 1;
105+
else trackIndex = 0;
106+
107+
loadTrack(trackIndex);
108+
playTrack();
109+
}
110+
function prevBtn() {
111+
if(trackIndex > 0)
112+
trackIndex -= 1;
113+
else trackIndex = track_list.length - 1;
86114

115+
loadTrack(trackIndex);
116+
playTrack();
117+
}

0 commit comments

Comments
 (0)