Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(414)

Side by Side Diff: ppapi/examples/video_capture/video_capture.html

Issue 9234064: Implement device enumeration for PPB_VideoCapture_Dev. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Changes in response to Antoine's comments. Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <!-- 3 <!--
4 Copyright (c) 2011 The Chromium Authors. All rights reserved. 4 Copyright (c) 2012 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 Capture Example</title> 9 <title>Video Capture Example</title>
10 <script type="text/javascript">
11 var device_array = [];
12
13 function HandleMessage(message_event) {
14 if (message_event.data) {
15 if (message_event.data == 'EnumerationFailed') {
16 var status = document.getElementById('status');
17 status.innerText = 'Device enumeration failed!';
18 } else {
19 device_array = message_event.data.split('#__#');
20
21 var list = document.getElementById('device_list');
22 for (var i = 0; i < device_array.length; ++i) {
23 var list_item = document.createElement('li');
24 var link = document.createElement('a');
25 link.href = 'javascript:UseDevice(' + i + ');';
26 link.innerText = device_array[i];
27 list_item.appendChild(link);
28 list.appendChild(list_item);
29 }
30 }
31 }
32 }
33
34 function UseDevice(index) {
35 var in_use_device = document.getElementById('in_use_device');
36 in_use_device.innerText = device_array[index];
37 var plugin = document.getElementById('plugin');
38 plugin.postMessage(index);
39 }
40
41 function UseDefaultDevice() {
42 var in_use_device = document.getElementById('in_use_device');
43 in_use_device.innerText = 'Default';
44 var plugin = document.getElementById('plugin');
45 plugin.postMessage('UseDefault');
46 }
47
48 function Initialize() {
49 var plugin = document.getElementById('plugin');
50 plugin.addEventListener('message', HandleMessage, false);
51 plugin.postMessage('PageInitialized');
52 }
53
54 document.addEventListener('DOMContentLoaded', Initialize, false);
55 </script>
10 </head> 56 </head>
11 57
12 <body> 58 <body>
13 59 <embed id="plugin" type="application/x-ppapi-example-video-capture"
14 <embed id="plugin" type="application/x-ppapi-example-video-capture" 60 width="320" height="240"/>
15 width="320" height="240"/> 61 <div>
16 62 <div style="margin-bottom:10px">In-use device:
63 <span id="in_use_device" style="font-weight:bold">None</span>
64 </div>
65 <div>Available device(s), click to activate/switch:
66 <ul id="device_list">
67 <li><a href="javascript:UseDefaultDevice();">Default</a></li>
68 </ul>
69 </div>
70 <div id="status"></div>
71 </div>
17 </body> 72 </body>
18 </html> 73 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698