diff --git a/openvidu-browser/src/OpenVidu/OpenVidu.ts b/openvidu-browser/src/OpenVidu/OpenVidu.ts index 0810d715..fe4e90bc 100644 --- a/openvidu-browser/src/OpenVidu/OpenVidu.ts +++ b/openvidu-browser/src/OpenVidu/OpenVidu.ts @@ -466,7 +466,8 @@ export class OpenVidu { if (!!publisherProperties.videoSource && typeof publisherProperties.videoSource === 'string') { - if (publisherProperties.videoSource === 'screen') { + if (publisherProperties.videoSource === 'screen' || + (platform.name!.indexOf('Firefox') !== -1 && publisherProperties.videoSource === 'window')) { if (platform.name !== 'Chrome' && platform.name!.indexOf('Firefox') === -1) { const error = new OpenViduError(OpenViduErrorName.SCREEN_SHARING_NOT_SUPPORTED, 'You can only screen share in desktop Chrome and Firefox. Detected browser: ' + platform.name); @@ -506,9 +507,11 @@ export class OpenVidu { }); } else { - // Default screen sharing extension for Chrome + // Default screen sharing extension for Chrome (or is Firefox) - screenSharingAuto.getScreenId((error, sourceId, screenConstraints) => { + const firefoxString = platform.name!.indexOf('Firefox') !== -1 ? publisherProperties.videoSource : undefined; + + screenSharingAuto.getScreenId(firefoxString, (error, sourceId, screenConstraints) => { if (!!error) { if (error === 'not-installed') { const extensionUrl = !!this.advancedConfiguration.screenShareChromeExtension ? this.advancedConfiguration.screenShareChromeExtension : diff --git a/openvidu-browser/src/OpenViduInternal/Interfaces/Public/PublisherProperties.ts b/openvidu-browser/src/OpenViduInternal/Interfaces/Public/PublisherProperties.ts index 55df2229..b710c604 100644 --- a/openvidu-browser/src/OpenViduInternal/Interfaces/Public/PublisherProperties.ts +++ b/openvidu-browser/src/OpenViduInternal/Interfaces/Public/PublisherProperties.ts @@ -75,6 +75,7 @@ export interface PublisherProperties { * - `"screen"` to screen-share. We provide a default screen-shraring extension for Chrome that can run in any domain, but you can customize it so it has your own icon, your own name, etc. Visit this * [GitHub repository](https://github.com/OpenVidu/openvidu-screen-sharing-chrome-extension/) to learn how. Once you have uploaded your own extension to Chrome Web Store, * simply call `OpenVidu.setAdvancedConfiguration({screenShareChromeExtension : "https://chrome.google.com/webstore/detail/YOUR_EXTENSION_NAME/YOUR_EXTENSION_ID"})` before calling `OpenVidu.initPublisher(targetElement, {videoSource: "screen"})`. + * For Firefox `"screen"` string will ask for permissions to share the entire screen. To ask for a specific window or application, use `"window"` string instead (this only applies to Firefox). * - A MediaStreamTrack obtained from a MediaStream object with [[OpenVidu.getUserMedia]] * - `false` or null to have an audio-only publisher * @default _Default camera_ diff --git a/openvidu-browser/src/OpenViduInternal/ScreenSharing/Screen-Capturing-Auto.js b/openvidu-browser/src/OpenViduInternal/ScreenSharing/Screen-Capturing-Auto.js index 6b1ea9ec..5947e717 100644 --- a/openvidu-browser/src/OpenViduInternal/ScreenSharing/Screen-Capturing-Auto.js +++ b/openvidu-browser/src/OpenViduInternal/ScreenSharing/Screen-Capturing-Auto.js @@ -23,7 +23,7 @@ getScreenId(function (error, sourceId, screen_constraints) { }, 'pass second parameter only if you want system audio'); */ -window.getScreenId = function (callback, custom_parameter) { +window.getScreenId = function (firefoxString, callback, custom_parameter) { if (navigator.userAgent.indexOf('Edge') !== -1 && (!!navigator.msSaveOrOpenBlob || !!navigator.msSaveBlob)) { // microsoft edge => navigator.getDisplayMedia(screen_constraints).then(onSuccess, onFailure); callback({ @@ -38,8 +38,8 @@ window.getScreenId = function (callback, custom_parameter) { if (!!navigator.mozGetUserMedia) { callback(null, 'firefox', { video: { - mozMediaSource: 'window', - mediaSource: 'window' + mozMediaSource: firefoxString, + mediaSource: firefoxString } }); return;