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

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

Issue 9557007: PPB_AudioInput_Dev: support multiple audio input devices - Part 1. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Changes in response to Trung's comments. Created 8 years, 9 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/audio_input/audio_input.cc ('k') | ppapi/proxy/ppapi_messages.h » ('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) 2011 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>Audio Input Example</title> 9 <title>Audio Input Example</title>
10 <script type="text/javascript">
11 var device_array = [];
12
13 function HandleMessage(message_event) {
14 if (message_event.data) {
15 var status = document.getElementById('status');
16 if (message_event.data == 'EnumerationFailed') {
17 status.innerText = 'Device enumeration failed!';
18 } else if (message_event.data == 'OpenFailed') {
19 status.innerText = 'Open device failed!';
20 } else if (message_event.data == 'StartFailed') {
21 status.innerText = 'Start capturing failed!';
22 } else if (message_event.data == 'StopFailed') {
23 status.innerText = 'Stop capturing failed!';
24 } else {
25 device_array = message_event.data.split('#__#');
26
27 var list = document.getElementById('device_list');
28 for (var i = 0; i < device_array.length; ++i) {
29 var list_item = document.createElement('li');
30 var link = document.createElement('a');
31 link.href = 'javascript:UseDesignatedDevice(' + i + ');';
32 link.innerText = device_array[i];
33 list_item.appendChild(link);
34 list.appendChild(list_item);
35 }
36 }
37 }
38 }
39
40 function UseDesignatedDevice(index) {
41 UseDevice(device_array[index], index);
42 }
43
44 function UseDefaultDevice(use_0_1_interface) {
45 var display_text = use_0_1_interface ? 'Default(v0.1)' : 'Default';
46 var command = use_0_1_interface ? 'UseDefault(v0.1)' : 'UseDefault';
47 UseDevice(display_text, command);
48 }
49
50 function UseDevice(display_text, command) {
51 var in_use_device = document.getElementById('in_use_device');
52 in_use_device.innerText = display_text;
53 var plugin = document.getElementById('plugin');
54 plugin.postMessage(command);
55
56 var available_devices = document.getElementById('available_devices');
57 available_devices.parentNode.removeChild(available_devices);
58
59 var control_panel = document.getElementById('control_panel');
60 var link = document.createElement('a');
61 link.href = 'javascript:Stop();';
62 link.innerText = 'Stop';
63 control_panel.appendChild(link);
64 }
65
66 function Stop() {
67 var plugin = document.getElementById('plugin');
68 plugin.postMessage('Stop');
69 }
70
71 function Initialize() {
72 var plugin = document.getElementById('plugin');
73 plugin.addEventListener('message', HandleMessage, false);
74 plugin.postMessage('PageInitialized');
75 }
76
77 document.addEventListener('DOMContentLoaded', Initialize, false);
78 </script>
10 </head> 79 </head>
11 80
12 <body> 81 <body>
13 82 <embed id="plugin" type="application/x-ppapi-example-audio-input"
14 <embed id="plugin" type="application/x-ppapi-example-audio-input" 83 width="800" height="400"/>
15 width="800" height="400"/> 84 <div style="margin-bottom:10px">In-use device:
16 85 <span id="in_use_device" style="font-weight:bold">None</span>
86 </div>
87 <div id="available_devices">
88 Available device(s), choose one to open:
89 <ul id="device_list">
90 <li><a href="javascript:UseDefaultDevice(true);">
91 Default - use interface version 0.1</a></li>
92 <li><a href="javascript:UseDefaultDevice(false);">
93 Default - use interface version 0.2 and NULL device ref</a></li>
94 </ul>
95 </div>
96 <div id="control_panel"></div>
97 <div id="status"></div>
17 </body> 98 </body>
18 </html> 99 </html>
OLDNEW
« no previous file with comments | « ppapi/examples/audio_input/audio_input.cc ('k') | ppapi/proxy/ppapi_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698