forked from snipat/cocotte
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathson.html
More file actions
37 lines (31 loc) · 784 Bytes
/
son.html
File metadata and controls
37 lines (31 loc) · 784 Bytes
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
<html>
<head>
<style>
.hide{
display:none;
}
</style>
</head>
<body>
<input id="bt" type="button" value="Accept">
<audio id="au" preload="auto" src="https://freesound.org/data/previews/475/475736_4397472-lq.mp3"></audio>
<script type="text/javascript">
const audio = document.getElementById("au");
let bt = document.getElementById("bt");
console.log(audio);
bt.addEventListener("click", ()=>{
audio.play();
});
const startPlaying = ()=>{
audio.removeEventListener('playing', startPlaying);
bt.classList.add("hide");
audio.src = 'https://freesound.org/data/previews/475/475736_4397472-lq.mp3';
audio.play();
}
audio.addEventListener('playing', startPlaying);
audio.addEventListener('error', ()=>{
console.log("error");
});
</script>
</body>
</html>