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

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: . 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
« no previous file with comments | « ppapi/examples/video_capture/video_capture.cc ('k') | ppapi/ppapi_shared.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 if (message_event.data == 'OpenFailed') {
19 var status = document.getElementById('status');
20 status.innerText = 'Open device failed!';
21 } else {
22 device_array = message_event.data.split('#__#');
23
24 var list = document.getElementById('device_list');
25 for (var i = 0; i < device_array.length; ++i) {
26 var list_item = document.createElement('li');
27 var link = document.createElement('a');
28 link.href = 'javascript:UseDesignatedDevice(' + i + ');';
29 link.innerText = device_array[i];
30 list_item.appendChild(link);
31 list.appendChild(list_item);
32 }
33 }
34 }
35 }
36
37 function UseDesignatedDevice(index) {
38 UseDevice(device_array[index], index);
39 }
40
41 function UseDefaultDevice(use_0_1_interface) {
42 var display_text = use_0_1_interface ? 'Default(v0.1)' : 'Default';
43 var command = use_0_1_interface ? 'UseDefault(v0.1)' : 'UseDefault';
44 UseDevice(display_text, command);
45 }
46
47 function UseDevice(display_text, command) {
48 var in_use_device = document.getElementById('in_use_device');
49 in_use_device.innerText = display_text;
50 var plugin = document.getElementById('plugin');
51 plugin.postMessage(command);
52
53 var available_devices = document.getElementById('available_devices');
54 available_devices.parentNode.removeChild(available_devices);
55
56 var control_panel = document.getElementById('control_panel');
57 var link = document.createElement('a');
58 link.href = 'javascript:Stop();';
59 link.innerText = 'Stop';
60 control_panel.appendChild(link);
61 }
62
63 function Stop() {
64 var plugin = document.getElementById('plugin');
65 plugin.postMessage('Stop');
66 }
67
68 function Initialize() {
69 var plugin = document.getElementById('plugin');
70 plugin.addEventListener('message', HandleMessage, false);
71 plugin.postMessage('PageInitialized');
72 }
73
74 document.addEventListener('DOMContentLoaded', Initialize, false);
75 </script>
10 </head> 76 </head>
11 77
12 <body> 78 <body>
13 79 <embed id="plugin" type="application/x-ppapi-example-video-capture"
14 <embed id="plugin" type="application/x-ppapi-example-video-capture" 80 width="320" height="240"/>
15 width="320" height="240"/> 81 <div style="margin-bottom:10px">In-use device:
16 82 <span id="in_use_device" style="font-weight:bold">None</span>
83 </div>
84 <div id="available_devices">
85 Available device(s), choose one to open:
86 <ul id="device_list">
87 <li><a href="javascript:UseDefaultDevice(true);">
88 Default - use interface version 0.1</a></li>
89 <li><a href="javascript:UseDefaultDevice(false);">Default</a></li>
90 </ul>
91 </div>
92 <div id="control_panel"></div>
93 <div id="status"></div>
17 </body> 94 </body>
18 </html> 95 </html>
OLDNEW
« no previous file with comments | « ppapi/examples/video_capture/video_capture.cc ('k') | ppapi/ppapi_shared.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698