Browse Source

feat(ScreenObtainer): fix support for old getDisplayMedia

Chrome 71 does not support inline installs, but has navigator.getDisplayMedia
behind a flag. Support this case.
dev1
Saúl Ibarra Corretgé 6 years ago
parent
commit
88731cd9dc
2 changed files with 12 additions and 3 deletions
  1. 10
    1
      modules/RTC/ScreenObtainer.js
  2. 2
    2
      modules/browser/BrowserCapabilities.js

+ 10
- 1
modules/RTC/ScreenObtainer.js View File

304
      * @param errorCallback - The error callback.
304
      * @param errorCallback - The error callback.
305
      */
305
      */
306
     obtainScreenFromGetDisplayMedia(options, callback, errorCallback) {
306
     obtainScreenFromGetDisplayMedia(options, callback, errorCallback) {
307
-        navigator.mediaDevices.getDisplayMedia({ video: true })
307
+        let getDisplayMedia;
308
+
309
+        if (navigator.getDisplayMedia) {
310
+            getDisplayMedia = navigator.getDisplayMedia.bind(navigator);
311
+        } else {
312
+            // eslint-disable-next-line max-len
313
+            getDisplayMedia = navigator.mediaDevices.getDisplayMedia.bind(navigator.mediaDevices);
314
+        }
315
+
316
+        getDisplayMedia({ video: true })
308
             .then(stream => {
317
             .then(stream => {
309
                 let applyConstraintsPromise;
318
                 let applyConstraintsPromise;
310
 
319
 

+ 2
- 2
modules/browser/BrowserCapabilities.js View File

282
      * @returns {boolean} {@code true} if the browser supposrts getDisplayMedia.
282
      * @returns {boolean} {@code true} if the browser supposrts getDisplayMedia.
283
      */
283
      */
284
     supportsGetDisplayMedia() {
284
     supportsGetDisplayMedia() {
285
-        return navigator.mediaDevices
286
-            && navigator.mediaDevices.getDisplayMedia !== undefined;
285
+        return typeof navigator.getDisplayMedia !== 'undefined'
286
+            || typeof navigator.mediaDevices.getDisplayMedia !== 'undefined';
287
     }
287
     }
288
 
288
 
289
     /**
289
     /**

Loading…
Cancel
Save