openvidu-browser: allow selecting "window" or "screen" as videoSource in Firefox

pull/109/merge
pabloFuente 2018-09-03 10:31:20 +02:00
parent 0cddbbf745
commit a52c4feb71
3 changed files with 10 additions and 6 deletions

View File

@ -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 :

View File

@ -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_

View File

@ -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;