-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
45 lines (35 loc) · 1.16 KB
/
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
<!DOCTYPE html>
<html>
<body>
<audio id="myAudio">
<source src="https://www.w3schools.com/jsref/horse.ogg" type="audio/ogg">
<source src="https://www.w3schools.com/jsref/horse.mp3" type="audio/mp3">
Your browser does not support the audio element.
</audio>
<p>Click the buttons to play or pause the audio. 2</p>
<button onclick="playAudio()" type="button">Play Audio</button>
<button onclick="pauseAudio()" type="button">Pause Audio</button>
<script>
var audio = document.getElementById("myAudio")
function playAudio() {
audio.play()
}
function pauseAudio() {
audio.pause()
}
window.onload = function () {
var audio = document.getElementById("myAudio")
console.log("Playing in 1000")
setTimeout(function () {
console.log("Now playing...")
try {
audio.play()
console.log("played.")
} catch (error) {
console.log("Failed....", error)
}
}, 1000)
}
</script>
</body>
</html>