OLD | NEW |
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 }); |
OLD | NEW |