Index: ppapi/examples/video_capture/video_capture.html |
diff --git a/ppapi/examples/video_capture/video_capture.html b/ppapi/examples/video_capture/video_capture.html |
index 44247faaaa8987825f052c0521cd6cc767331119..33c46509227347237769bf0674bde4c44bba3639 100644 |
--- a/ppapi/examples/video_capture/video_capture.html |
+++ b/ppapi/examples/video_capture/video_capture.html |
@@ -1,18 +1,73 @@ |
<!DOCTYPE html> |
<html> |
<!-- |
- Copyright (c) 2011 The Chromium Authors. All rights reserved. |
+ 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>Video Capture Example</title> |
-</head> |
+ <script type="text/javascript"> |
+ var device_array = []; |
-<body> |
+ function HandleMessage(message_event) { |
+ if (message_event.data) { |
+ if (message_event.data == 'EnumerationFailed') { |
+ var status = document.getElementById('status'); |
+ status.innerText = 'Device enumeration failed!'; |
+ } else { |
+ device_array = message_event.data.split('#__#'); |
+ |
+ var list = document.getElementById('device_list'); |
+ for (var i = 0; i < device_array.length; ++i) { |
+ var list_item = document.createElement('li'); |
+ var link = document.createElement('a'); |
+ link.href = 'javascript:UseDevice(' + i + ');'; |
+ link.innerText = device_array[i]; |
+ list_item.appendChild(link); |
+ list.appendChild(list_item); |
+ } |
+ } |
+ } |
+ } |
+ |
+ function UseDevice(index) { |
+ var in_use_device = document.getElementById('in_use_device'); |
+ in_use_device.innerText = device_array[index]; |
+ var plugin = document.getElementById('plugin'); |
+ plugin.postMessage(index); |
+ } |
-<embed id="plugin" type="application/x-ppapi-example-video-capture" |
- width="320" height="240"/> |
+ function UseDefaultDevice() { |
+ var in_use_device = document.getElementById('in_use_device'); |
+ in_use_device.innerText = 'Default'; |
+ var plugin = document.getElementById('plugin'); |
+ plugin.postMessage('UseDefault'); |
+ } |
+ function Initialize() { |
+ var plugin = document.getElementById('plugin'); |
+ plugin.addEventListener('message', HandleMessage, false); |
+ plugin.postMessage('PageInitialized'); |
+ } |
+ |
+ document.addEventListener('DOMContentLoaded', Initialize, false); |
+ </script> |
+</head> |
+ |
+<body> |
+ <embed id="plugin" type="application/x-ppapi-example-video-capture" |
+ width="320" height="240"/> |
+ <div> |
+ <div style="margin-bottom:10px">In-use device: |
+ <span id="in_use_device" style="font-weight:bold">None</span> |
+ </div> |
+ <div>Available device(s), click to activate/switch: |
+ <ul id="device_list"> |
+ <li><a href="javascript:UseDefaultDevice();">Default</a></li> |
+ </ul> |
+ </div> |
+ <div id="status"></div> |
+ </div> |
</body> |
</html> |