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

Side by Side Diff: chrome/common/extensions/docs/examples/api/desktopCapture/app.js

Issue 1321453004: Add maximum screen size into constraint for webkitGetuserMedia() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 function gotStream(stream) { 5 function gotStream(stream) {
6 console.log("Received local stream"); 6 console.log("Received local stream");
7 var video = document.querySelector("video"); 7 var video = document.querySelector("video");
8 video.src = URL.createObjectURL(stream); 8 video.src = URL.createObjectURL(stream);
9 localstream = stream; 9 localstream = stream;
10 stream.onended = function() { console.log("Ended"); }; 10 stream.onended = function() { console.log("Ended"); };
11 } 11 }
12 12
13 function getUserMediaError() { 13 function getUserMediaError() {
14 console.log("getUserMedia() failed."); 14 console.log("getUserMedia() failed.");
15 } 15 }
16 16
17 function onAccessApproved(id) { 17 function onAccessApproved(id) {
18 if (!id) { 18 if (!id) {
19 console.log("Access rejected."); 19 console.log("Access rejected.");
20 return; 20 return;
21 } 21 }
22
22 navigator.webkitGetUserMedia({ 23 navigator.webkitGetUserMedia({
23 audio:false, 24 audio:false,
24 video: { mandatory: { chromeMediaSource: "desktop", 25 video: {
25 chromeMediaSourceId: id } } 26 mandatory: {
27 chromeMediaSource: "desktop",
28 chromeMediaSourceId: id,
29 maxWidth:screen.width,
30 maxHeight:screen.height} }
26 }, gotStream, getUserMediaError); 31 }, gotStream, getUserMediaError);
27 } 32 }
28 33
29 var pending_request_id = null; 34 var pending_request_id = null;
30 35
31 document.querySelector('#start').addEventListener('click', function(e) { 36 document.querySelector('#start').addEventListener('click', function(e) {
32 pending_request_id = chrome.desktopCapture.chooseDesktopMedia( 37 pending_request_id = chrome.desktopCapture.chooseDesktopMedia(
33 ["screen", "window"], onAccessApproved); 38 ["screen", "window"], onAccessApproved);
34 }); 39 });
35 40
36 document.querySelector('#cancel').addEventListener('click', function(e) { 41 document.querySelector('#cancel').addEventListener('click', function(e) {
37 if (pending_request_id != null) { 42 if (pending_request_id != null) {
38 chrome.desktopCapture.cancelChooseDesktopMedia(pending_request_id); 43 chrome.desktopCapture.cancelChooseDesktopMedia(pending_request_id);
39 } 44 }
40 }); 45 });
41 46
42 document.querySelector('#startFromBackgroundPage') 47 document.querySelector('#startFromBackgroundPage')
43 .addEventListener('click', function(e) { 48 .addEventListener('click', function(e) {
44 chrome.runtime.sendMessage( 49 chrome.runtime.sendMessage(
45 {}, function(response) { console.log(response.farewell); }); 50 {}, function(response) { console.log(response.farewell); });
46 }); 51 });
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698