-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsink13.html
57 lines (46 loc) · 1.28 KB
/
sink13.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
47
48
49
50
51
52
53
54
55
56
57
<!DOCTYPE html>
<html>
<head>
<style>
div.hdn {
position:absolute;
top: 0px;
left: 0px;
right: 0px;
bottom: 0px;
overflow: hidden;
}
a.hdnlink {
color: rgba(0, 0, 0, 0.1);
text-decoration: none;
border-bottom: none;
}
</style>
</head>
<body>
<script>
var actx = new (AudioContext || webkitAudioContext)(),
src = "audio/sinkpart13.mp3",
audioData, srcNode; // global so we can access them from handlers
// Load some audio (CORS need to be allowed or we won't be able to decode the data)
fetch(src, {mode: "cors"}).then(function(resp) {return resp.arrayBuffer()}).then(decode);
// Decode the audio file, then start the show
function decode(buffer) {
actx.decodeAudioData(buffer, playLoop);
}
// Sets up a new source node as needed as stopping will render current invalid
function playLoop(abuffer) {
if (!audioData) audioData = abuffer; // create a reference for control buttons
srcNode = actx.createBufferSource(); // create audio source
srcNode.buffer = abuffer; // use decoded buffer
srcNode.connect(actx.destination); // create output
srcNode.loop = true; // takes care of perfect looping
srcNode.start(); // play...
};
</script>
<div class=hdn>
<a href="sink14.html">
<h1>(2)</h1>
</a>
</div>
</body>