From e567d9c69a9d1060ce99ed296de149eb0f64fb0b Mon Sep 17 00:00:00 2001 From: pabloFuente Date: Fri, 7 Sep 2018 10:07:58 +0200 Subject: [PATCH] openvidu-browser: OpenVidu.checkScreenSharingCapabilities. Opera support for screen-sharing --- openvidu-browser/src/OpenVidu/OpenVidu.ts | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/openvidu-browser/src/OpenVidu/OpenVidu.ts b/openvidu-browser/src/OpenVidu/OpenVidu.ts index c8466a47..56a2e547 100644 --- a/openvidu-browser/src/OpenVidu/OpenVidu.ts +++ b/openvidu-browser/src/OpenVidu/OpenVidu.ts @@ -289,6 +289,20 @@ export class OpenVidu { } + /** + * Checks if the browser supports screen-sharing. Chrome, Firefox and Opera support screen-sharing + * @returns 1 if the browser supports screen-sharing, 0 otherwise + */ + checkScreenSharingCapabilities(): number { + const browser = platform.name; + if ((browser !== 'Chrome') && (browser !== 'Firefox') && (browser !== 'Opera')) { + return 0; + } else { + return 1; + } + } + + /** * Collects information about the media input devices available on the system. You can pass property `deviceId` of a [[Device]] object as value of `audioSource` or `videoSource` properties in [[initPublisher]] method */ @@ -469,7 +483,7 @@ export class OpenVidu { if (publisherProperties.videoSource === 'screen' || (platform.name!.indexOf('Firefox') !== -1 && publisherProperties.videoSource === 'window')) { - if (platform.name !== 'Chrome' && platform.name!.indexOf('Firefox') === -1) { + if (platform.name !== 'Chrome' && platform.name!.indexOf('Firefox') === -1 && platform.name !== 'Opera') { const error = new OpenViduError(OpenViduErrorName.SCREEN_SHARING_NOT_SUPPORTED, 'You can only screen share in desktop Chrome and Firefox. Detected browser: ' + platform.name); console.error(error); reject(error); @@ -477,7 +491,7 @@ export class OpenVidu { if (!!this.advancedConfiguration.screenShareChromeExtension && !(platform.name!.indexOf('Firefox') !== -1)) { - // Custom screen sharing extension for Chrome + // Custom screen sharing extension for Chrome (and Opera) screenSharing.getScreenConstraints((error, screenConstraints) => { if (!!error || !!screenConstraints.mandatory && screenConstraints.mandatory.chromeMediaSource === 'screen') {