-
Notifications
You must be signed in to change notification settings - Fork 0
/
index2.html
42 lines (36 loc) · 1.34 KB
/
index2.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
<html>
<body style='font-size:40px'>
<div id=alldiv>
<div id=messagediv style='font-style:italic'>Loading…</div>
<div id=readystatediv style='font-style:italic'></div>
<script>
var audio = new Audio("/audio/audio_test.mp3")
var played = false
var start = function () {
if (played)
return;
played = true
audio.play()
messagediv.innerHTML = "Playing audio. <button style='font-size:inherit' onclick='audio.pause()'>Stop</button>"
alldiv.onclick = ''
}
audio.addEventListener('canplaythrough', start, false)
if (audio.readyState > 3)
start()
var loop = function () {
readystatediv.innerHTML = "readyState=" + audio.readyState
setTimeout(loop, 16)
}
loop()
alldiv.onclick = function () {
start()
}
alldiv.addEventListener('touchstart', start, false)
alldiv.addEventListener('click', start, false)
</script>
<div style='height:70vh;background:#EFE'>
The rest of the webpage takes up all of this space. On Safari audio will start on the first tap anywhere.
</div>
</div>
</body>
</html>