forked from cupnes/html_bgm_se_player
-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
46 lines (42 loc) · 963 Bytes
/
index.html
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
40
41
42
43
44
45
46
<html>
<body>
<!-- <audio src="g2s1.mp3" controls> -->
<button id="BGM">BGM</button>
<button id="SE1">SE1</button>
<button id="FO">FO</button>
<script>
var timerid = 0;
document.getElementById("FO").addEventListener("click", function(){
if (timerid != 0)
return;
timerid = setInterval(function(){
var tmp = bgm.volume - 0.1;
if (tmp > 0) {
bgm.volume = tmp;
} else {
bgm.pause();
bgm.volume = 1;
bgm.currentTime = 0;
clearInterval(timerid);
timerid = 0;
}
}, 500) ;
});
var bgm = new Audio();
bgm.src = "g2s1.mp3";
bgm.loop = true;
bgm.volume = 1;
document.getElementById("BGM").addEventListener("click", function(){
bgm.play();
});
var audio = new Audio();
audio.src = "sdgra17.mp3";
document.getElementById("SE1").addEventListener("click", function(){
if (audio.currentTime > 0) {
audio.currentTime = 0;
}
audio.play();
});
</script>
</body>
</html>