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

Unified Diff: ppapi/examples/enumerate_devices/enumerate_devices.html

Issue 11016007: Implement host side of sync EnumerateVideoCaptureDevices (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ppapi/examples/enumerate_devices/enumerate_devices.cc ('k') | ppapi/ppapi_tests.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/examples/enumerate_devices/enumerate_devices.html
diff --git a/ppapi/examples/enumerate_devices/enumerate_devices.html b/ppapi/examples/enumerate_devices/enumerate_devices.html
new file mode 100644
index 0000000000000000000000000000000000000000..d77cadbb0ae08583a37c9d036cc448f77e4c4adc
--- /dev/null
+++ b/ppapi/examples/enumerate_devices/enumerate_devices.html
@@ -0,0 +1,87 @@
+<!DOCTYPE html>
+<html>
+ <!--
+ Copyright (c) 2012 The Chromium Authors. All rights reserved.
+ Use of this source code is governed by a BSD-style license that can be
+ found in the LICENSE file.
+ -->
+<head>
+ <title>Enumerate Devices Example</title>
+ <script type="text/javascript">
+ var device_array = [];
+ var enumerating = false;
+
+ function HandleMessage(message_event) {
+ if (message_event.data) {
+ var status = document.getElementById('status');
+ if (message_event.data == 'EnumerationFailed') {
+ status.innerText = 'Device enumeration failed!';
+ } else {
+ devices_data =
+ message_event.data.substring('EnumerationSuccess'.length);
+ if (devices_data.length > 0)
+ device_array = devices_data.split('#__#');
+ else
+ devices_array = [];
+
+ var list = document.getElementById('device_list');
+ if (devices_array.length == 0)
+ list.innerHTML = 'No devices.';
+ for (var i = 0; i < device_array.length; ++i) {
+ var list_item = document.createElement('li');
+ var span = document.createElement('span');
+ span.innerText = device_array[i];
+ list_item.appendChild(span);
+ list.appendChild(list_item);
+ }
+ status.innerText = 'Device enumeration success!';
+ }
+ enumerating = false;
+ }
+ }
+
+ function EnumerateDevices(sync) {
+ if (enumerating)
+ return;
+ enumerating = true;
+ var status = document.getElementById('status');
+ var plugin = document.getElementById('plugin');
+ if (sync) {
+ status.innerText = 'Enumerating devices sync...'
+ plugin.postMessage('EnumerateDevicesSync');
+ } else {
+ status.innerText = 'Enumerating devices async...'
+ plugin.postMessage('EnumerateDevicesAsync');
+ }
+ }
+
+ function Initialize() {
+ var plugin = document.getElementById('plugin');
+ plugin.addEventListener('message', HandleMessage, false);
+ EnumerateDevices(true);
+ }
+
+ document.addEventListener('DOMContentLoaded', Initialize, false);
+ </script>
+</head>
+
+<body>
+ <embed id="plugin" type="application/x-ppapi-example-enumerate-devices"
+ width=0 height=0 />
+ <div>
+ Press a link to enumerate video devices:
+ <ul>
+ <li><a href="javascript:EnumerateDevices(true)">Enumerate devices sync</a>
+ (only implemented for out-of-process)</li>
+ <li><a href="javascript:EnumerateDevices(false)">Enumerate devices async</a></li>
+ </ul>
+ </div>
+ <div id="available_devices">
+ Available device(s):
+ <ul id="device_list">No devices.</ul>
+ </div>
+ <div>
+ Status: <span id="status"></span>
+ </div>
+</body>
+</html>
« no previous file with comments | « ppapi/examples/enumerate_devices/enumerate_devices.cc ('k') | ppapi/ppapi_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698