OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <!-- | 3 <!-- |
4 Copyright 2015 The Chromium Authors. All rights reserved. | 4 Copyright 2015 The Chromium Authors. All rights reserved. |
5 Use of this source code is governed by a BSD-style license that can be | 5 Use of this source code is governed by a BSD-style license that can be |
6 found in the LICENSE file. | 6 found in the LICENSE file. |
7 --> | 7 --> |
8 <head> | 8 <head> |
9 <title>Video Encoder Example</title> | 9 <title>Video Encoder Example</title> |
10 <script type="text/javascript"> | 10 <script type="text/javascript"> |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 video.pause(); | 52 video.pause(); |
53 track.stop(); | 53 track.stop(); |
54 } | 54 } |
55 | 55 |
56 function saveBlob(blob) { | 56 function saveBlob(blob) { |
57 var blobUrl = URL.createObjectURL(blob); | 57 var blobUrl = URL.createObjectURL(blob); |
58 window.location = blobUrl; | 58 window.location = blobUrl; |
59 } | 59 } |
60 | 60 |
61 function handleMessage(msg) { | 61 function handleMessage(msg) { |
62 if (msg.data.name == 'started') { | 62 if (msg.data.name == 'data') { |
63 console.log('recording!'); | |
64 } else if (msg.data.name == 'data') { | |
65 appendData(msg.data.data); | 63 appendData(msg.data.data); |
66 } else if (msg.data.name == 'stopped') { | |
67 console.log('done recording! bytes: ' + dataArray.byteLength); | |
68 } else if (msg.data.name == 'supportedProfiles') { | 64 } else if (msg.data.name == 'supportedProfiles') { |
69 console.log('profiles: ', msg.data); | 65 console.log('profiles: ', msg.data); |
70 var profileList = $('profileList'); | 66 var profileList = $('profileList'); |
71 for (var i = 0; i < msg.data.profiles.length; i++) { | 67 for (var i = 0; i < msg.data.profiles.length; i++) { |
72 var item = document.createElement('option'); | 68 var item = document.createElement('option'); |
73 item.label = item.value = msg.data.profiles[i]; | 69 item.label = item.value = msg.data.profiles[i]; |
74 profileList.appendChild(item); | 70 profileList.appendChild(item); |
75 } | 71 } |
| 72 } else if (msg.data.name == 'log') { |
| 73 console.log(msg.data.message); |
76 } | 74 } |
77 } | 75 } |
78 | 76 |
79 function resetData() { | 77 function resetData() { |
80 window.dataArray = new ArrayBuffer(0); | 78 window.dataArray = new ArrayBuffer(0); |
81 } | 79 } |
82 | 80 |
83 function appendData(data) { | 81 function appendData(data) { |
84 var tmp = new Uint8Array(dataArray.byteLength + data.byteLength); | 82 var tmp = new Uint8Array(dataArray.byteLength + data.byteLength); |
85 tmp.set(new Uint8Array(dataArray), 0 ); | 83 tmp.set(new Uint8Array(dataArray), 0 ); |
86 tmp.set(new Uint8Array(data), dataArray.byteLength); | 84 tmp.set(new Uint8Array(data), dataArray.byteLength); |
87 dataArray = tmp.buffer; | 85 dataArray = tmp.buffer; |
88 $('length').innerHTML = ' Size: ' + dataArray.byteLength + ' bytes'; | 86 $('length').textContent = ' Size: ' + dataArray.byteLength + ' bytes'; |
89 } | 87 } |
90 | 88 |
91 function initialize() { | 89 function initialize() { |
92 plugin = $('plugin'); | 90 plugin = $('plugin'); |
93 plugin.addEventListener('message', handleMessage, false); | 91 plugin.addEventListener('message', handleMessage, false); |
94 | 92 |
95 video = $('video'); | 93 video = $('video'); |
96 | 94 |
97 $('start').addEventListener('click', function (e) { | 95 $('start').addEventListener('click', function (e) { |
98 resetData(); | 96 resetData(); |
(...skipping 21 matching lines...) Expand all Loading... |
120 <input type="button" id="stop" value="Stop Recording"/> | 118 <input type="button" id="stop" value="Stop Recording"/> |
121 <input type="button" id="download" value="Download Recording"/> | 119 <input type="button" id="download" value="Download Recording"/> |
122 <div id="length"></div> | 120 <div id="length"></div> |
123 <br> | 121 <br> |
124 <div> | 122 <div> |
125 <embed id="plugin" type="application/x-ppapi-example-video-encode"/> | 123 <embed id="plugin" type="application/x-ppapi-example-video-encode"/> |
126 <video id="video" width="640" height="480"/> | 124 <video id="video" width="640" height="480"/> |
127 </div> | 125 </div> |
128 </body> | 126 </body> |
129 </html> | 127 </html> |
OLD | NEW |