Merge pull request #16549 from zfox23/autoMinimizeScreenshare

DEV-2832, DEV-2816, DEV-2843: Auto-minimize Screen Share; enable switching between windows; prevent video dropout
This commit is contained in:
Zach Fox 2019-11-27 14:02:34 -05:00 committed by GitHub
commit d0a3aeb7cf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -7,6 +7,8 @@
// Distributed under the Apache License, Version 2.0. // Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
const { remote } = require('electron');
// Helpers // Helpers
function handleError(error) { function handleError(error) {
if (error) { if (error) {
@ -188,6 +190,10 @@ function stopSharing() {
// Callback to start publishing after we have setup the chromium stream // Callback to start publishing after we have setup the chromium stream
function gotStream(stream) { function gotStream(stream) {
if (localStream) {
stopSharing();
}
localStream = stream; localStream = stream;
startTokboxPublisher(localStream); startTokboxPublisher(localStream);
@ -206,6 +212,9 @@ function onAccessApproved(desktop_id) {
console.log('Desktop Capture access rejected.'); console.log('Desktop Capture access rejected.');
return; return;
} }
document.getElementById('screenshare').style.visibility = "block"; document.getElementById('screenshare').style.visibility = "block";
desktopSharing = true; desktopSharing = true;
navigator.webkitGetUserMedia({ navigator.webkitGetUserMedia({
@ -221,6 +230,7 @@ function onAccessApproved(desktop_id) {
} }
} }
}, gotStream, handleError); }, gotStream, handleError);
remote.getCurrentWindow().minimize();
} }
@ -248,11 +258,15 @@ var publisher;
function startTokboxPublisher(stream) { function startTokboxPublisher(stream) {
publisher = document.createElement("div"); publisher = document.createElement("div");
var publisherOptions = { var publisherOptions = {
videoSource: stream.getVideoTracks()[0], audioFallbackEnabled: false,
audioSource: null, audioSource: null,
fitMode: 'contain',
frameRate: 30,
height: 720,
insertMode: 'append', insertMode: 'append',
width: 1280, publishAudio: false,
height: 720 videoSource: stream.getVideoTracks()[0],
width: 1280
}; };
publisher = OT.initPublisher(publisher, publisherOptions, function(error){ publisher = OT.initPublisher(publisher, publisherOptions, function(error){