-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
33 lines (28 loc) · 829 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
const music = new Audio('On My Way.mp3');
// create
const songs = [
{
id: '1',
songName: `On My Way <br>
<div class="subtitle">Alan Walker</div`,
poster: "image/alan.png"
},
{
id: '2',
songName: `On My Way <br>
<div class="subtitle">Alan Walker</div`,
poster: "image/w.png"
}
]
Array.from(document.getElementsByClassName('songItem')).forEach((element, i)=>{
element.getElementsByTagName('img')[0].src = songs[i].poster;
element.getElementsByTagName('h5')[0].innerHTML = songs[i].songName;
})
let masterPlay = document.getElementById('masterPlay');
masterPlay.addEventListener('click',()=>{
if(music.paused || music.currentTime <= 0){
music.play();
}else{
music.pause();
}
})