|
14 | 14 | <body>
|
15 | 15 |
|
16 | 16 | <script>
|
17 |
| -navigator.webkitGetUserMedia({video: false, audio: true}, function(stream) { |
18 |
| - var context = new webkitAudioContext; |
19 |
| - mediaStreamSource = context.createMediaStreamSource(stream); |
20 |
| - processor = context.createJavaScriptNode(4096, 2, 2); |
21 |
| - |
22 |
| - processor.onaudioprocess = function(e) { |
23 |
| -// console.log(e.inputBuffer); |
24 |
| -// console.log(e.inputBuffer.getChannelData(0)); |
25 |
| - processor.onaudioprocess = undefined; |
26 |
| - stream.stop(); |
27 |
| - // Process the audio data found in e.inputBuffer |
28 |
| - }; |
29 |
| - |
30 |
| - mediaStreamSource.connect(processor); |
31 |
| - processor.connect(context.destination); |
32 |
| -}); |
33 |
| - |
34 |
| -navigator.webkitGetUserMedia({video: true, audio: false}, function(stream) { |
35 |
| - var canvas = document.createElement('canvas'); |
36 |
| - var ctx = canvas.getContext('2d'); |
37 |
| - |
38 |
| - video = document.createElement('video'); |
39 |
| - video.src = window.URL.createObjectURL(stream); |
40 |
| - |
41 |
| - video.addEventListener('loadeddata', function() { |
42 |
| - ctx.drawImage(video, 0, 0); |
43 |
| - var frame = ctx.getImageData(0, 0, video.videoWidth, video.videoHeight).data; |
44 |
| - var pixels = new Uint8Array(frame); // rgba |
45 |
| - console.log(pixels); |
46 |
| - |
47 |
| - stream.stop(); |
48 |
| - }); |
49 |
| -}); |
50 |
| -</script> |
51 |
| - |
52 | 17 | <a href="https://github.com/you"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_red_aa0000.png" alt="Fork me on GitHub"></a>
|
53 | 18 |
|
54 | 19 | <div style="margin-left: auto; margin-right: auto; width: 600px">
|
|
0 commit comments