-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmedia.html
64 lines (57 loc) · 1.38 KB
/
media.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
58
59
60
61
62
63
64
<style>
body {
background-color: #004444;
font-size: 30pt;
color: #00EEEE;
}
button {
font-size: 30pt;
margin: 2em;
}
</style>
<div class="testcase">
<h1>Web Audio test</h1>
<button onclick="osc()">Start oscillator</button>
<button onclick="stoposc()">Stop oscillator</button>
</div>
<div class="testcase">
<h1>Audio test</h1>
<audio src="t-rex-roar.mp3"></audio>
<button onclick="start('audio')">Start audio</button>
<button onclick="stop('audio')">Stop audio</button>
</div>
<div class="testcase">
<h1>Video test</h1>
<video></video>
<p>
<button onclick="addvid()">Add video</button>
<button onclick="start('video')">Start video</button>
<button onclick="stop('video')">Stop video</button>
</p>
</div>
<script>
function addvid() {
document.querySelector('video').src = "trailer_480p.mov";
}
function start(selector) {
document.querySelector(selector).play();
}
function stop(selector) {
document.querySelector(selector).pause();
}
var oscillator = null;
function osc() {
console.log("hi");
// create web audio api context
var audioCtx = new (window.AudioContext || window.webkitAudioContext)();
// create Oscillator node
oscillator = audioCtx.createOscillator();
oscillator.type = 'square';
oscillator.frequency.setValueAtTime(440, audioCtx.currentTime); // value in hertz
oscillator.connect(audioCtx.destination);
oscillator.start();
}
function stoposc() {
oscillator.stop()
}
</script>