Screen sharing bug fix

pull/88/merge
pabloFuente 2018-06-25 18:05:49 +02:00
parent ddfdefa731
commit 16393aa6eb
2 changed files with 27 additions and 26 deletions

View File

@ -410,24 +410,19 @@ export class OpenVidu {
reject(error); reject(error);
} else { } else {
if (!!this.advancedConfiguration.screenShareChromeExtension) { if (!!this.advancedConfiguration.screenShareChromeExtension && !(platform.name!.indexOf('Firefox') !== -1)) {
// Custom screen sharing extension for Chrome // Custom screen sharing extension for Chrome
const extensionId = this.advancedConfiguration.screenShareChromeExtension.split('/').pop()!!.trim();
screenSharing.getChromeExtensionStatus(extensionId, (status) => {
if (status === 'installed-enabled' || (status === 'not-chrome' && platform.name!.indexOf('Firefox') !== -1)) {
screenSharing.getScreenConstraints((error, screenConstraints) => { screenSharing.getScreenConstraints((error, screenConstraints) => {
if (!!error && error === 'permission-denied') { if (!!error || !!screenConstraints.mandatory && screenConstraints.mandatory.chromeMediaSource === 'screen') {
if (error === 'permission-denied' || error === 'PermissionDeniedError') {
const error = new OpenViduError(OpenViduErrorName.SCREEN_CAPTURE_DENIED, 'You must allow access to one window of your desktop'); const error = new OpenViduError(OpenViduErrorName.SCREEN_CAPTURE_DENIED, 'You must allow access to one window of your desktop');
console.error(error); console.error(error);
reject(error); reject(error);
} else { } else {
mediaConstraints.video = screenConstraints; const extensionId = this.advancedConfiguration.screenShareChromeExtension!.split('/').pop()!!.trim();
resolve(mediaConstraints); screenSharing.getChromeExtensionStatus(extensionId, (status) => {
}
});
}
if (status === 'installed-disabled') { if (status === 'installed-disabled') {
const error = new OpenViduError(OpenViduErrorName.SCREEN_EXTENSION_DISABLED, 'You must enable the screen extension'); const error = new OpenViduError(OpenViduErrorName.SCREEN_EXTENSION_DISABLED, 'You must enable the screen extension');
console.error(error); console.error(error);
@ -439,6 +434,12 @@ export class OpenVidu {
reject(error); reject(error);
} }
}); });
}
} else {
mediaConstraints.video = screenConstraints;
resolve(mediaConstraints);
}
});
} else { } else {
// Default screen sharing extension for Chrome // Default screen sharing extension for Chrome

View File

@ -17,7 +17,6 @@ window.addEventListener('message', function (event) {
function onMessageCallback(data) { function onMessageCallback(data) {
// "cancel" button is clicked // "cancel" button is clicked
if (data == 'PermissionDeniedError') { if (data == 'PermissionDeniedError') {
chromeMediaSource = 'PermissionDeniedError';
if (screenCallback) if (screenCallback)
return screenCallback('PermissionDeniedError'); return screenCallback('PermissionDeniedError');
else else
@ -109,6 +108,7 @@ function getScreenConstraintsWithAudio(callback) {
// this function explains how to use above methods/objects // this function explains how to use above methods/objects
function getScreenConstraints(callback, captureSourceIdWithAudio) { function getScreenConstraints(callback, captureSourceIdWithAudio) {
sourceId = '';
var firefoxScreenConstraints = { var firefoxScreenConstraints = {
mozMediaSource: 'window', mozMediaSource: 'window',
mediaSource: 'window' mediaSource: 'window'