openvidu-browser: allow 'window' string as videoSource in modern Chrome/Firefox

pull/331/head
pabloFuente 2019-09-25 18:12:50 +02:00
parent 47312205c5
commit e78f13db54
2 changed files with 5 additions and 4 deletions

View File

@ -546,7 +546,8 @@ export class OpenVidu {
let mustAskForAudioTrackLater = false; let mustAskForAudioTrackLater = false;
if (typeof options.videoSource === 'string') { if (typeof options.videoSource === 'string') {
if (options.videoSource === 'screen' || if (options.videoSource === 'screen' ||
(platform.name!.indexOf('Firefox') !== -1 && options.videoSource === 'window')) { options.videoSource === 'window' ||
(platform.name === 'Electron' && options.videoSource.startsWith('screen:'))) {
// Screen sharing // Screen sharing
mustAskForAudioTrackLater = options.audioSource !== null && options.audioSource !== false; mustAskForAudioTrackLater = options.audioSource !== null && options.audioSource !== false;
if (navigator.mediaDevices['getDisplayMedia'] && platform.name !== 'Electron') { if (navigator.mediaDevices['getDisplayMedia'] && platform.name !== 'Electron') {
@ -680,7 +681,7 @@ export class OpenVidu {
if (!!publisherProperties.videoSource && typeof publisherProperties.videoSource === 'string') { if (!!publisherProperties.videoSource && typeof publisherProperties.videoSource === 'string') {
if (publisherProperties.videoSource === 'screen' || if (publisherProperties.videoSource === 'screen' ||
(platform.name!.indexOf('Firefox') !== -1 && publisherProperties.videoSource === 'window') || publisherProperties.videoSource === 'window' ||
(platform.name === 'Electron' && publisherProperties.videoSource.startsWith('screen:'))) { (platform.name === 'Electron' && publisherProperties.videoSource.startsWith('screen:'))) {
if (!this.checkScreenSharingCapabilities()) { if (!this.checkScreenSharingCapabilities()) {
@ -740,7 +741,7 @@ export class OpenVidu {
} else { } else {
if (navigator.mediaDevices['getDisplayMedia']) { if (navigator.mediaDevices['getDisplayMedia']) {
// getDisplayMedia support (Chrome >= 72, Firefox >= 52) // getDisplayMedia support (Chrome >= 72, Firefox >= 66)
resolve(mediaConstraints); resolve(mediaConstraints);
} else { } else {
// Default screen sharing extension for Chrome/Opera, or is Firefox < 66 // Default screen sharing extension for Chrome/Opera, or is Firefox < 66

View File

@ -75,7 +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 * - `"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, * [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"})`. * 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). * For Firefox (<66) `"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]] * - A MediaStreamTrack obtained from a MediaStream object with [[OpenVidu.getUserMedia]]
* - `false` or null to have an audio-only publisher * - `false` or null to have an audio-only publisher
* @default _Default camera_ * @default _Default camera_