-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
32 lines (31 loc) · 815 Bytes
/
script.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
var list = document.getElementsByTagName('audio');
function play(idString){
//pause all other audio
for(var i = 0; i < list.length; i++){
list[i].pause();
}
var audio = document.getElementById(idString);
if(!audio.paused){ //if audio is playing
audio.pause();
}
else{
audio.load();
audio.play();
}
}
//checks if a song is playing and sets "playing" to that song and returns true
// or returns false meaning that no song is playing.
function checkPlaying()
{
for(var i = 0; i < list.length; i++){
if(!list[i].paused){ //this element is playing
document.getElementById("playing").innerHTML = "♫: " + list[i].getAttribute("title");
setTimeout(checkPlaying,500);
return;
}
}
setTimeout(checkPlaying,500);
document.getElementById("playing").innerHTML = "";
return;
}
checkPlaying();