From c8ace18f85df4e380402fdd0422bb2dc79c72d02 Mon Sep 17 00:00:00 2001 From: Pedro Beschorner Marin Date: Wed, 28 Oct 2020 11:18:34 -0300 Subject: [PATCH] Enumerate devices even if first getUserMedia fails The first getUserMedia was not supposed to be considered critical to the whole video preview flow. Scenarios where the user has multiple media sources and one of them was already in use or had some malfunction problem were forcing a global skip at the video preview modal even if one of them was available to be used. --- .../ui/components/video-preview/component.jsx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/bigbluebutton-html5/imports/ui/components/video-preview/component.jsx b/bigbluebutton-html5/imports/ui/components/video-preview/component.jsx index f8ede54972..5f34bf399c 100755 --- a/bigbluebutton-html5/imports/ui/components/video-preview/component.jsx +++ b/bigbluebutton-html5/imports/ui/components/video-preview/component.jsx @@ -215,12 +215,12 @@ class VideoPreview extends Component { // skipped then we get devices with no labels if (hasMediaDevices) { try { + let firstAllowedDeviceId; navigator.mediaDevices.getUserMedia({ audio: false, video: { facingMode: 'user' } }) .then((stream) => { if (!this._isMounted) return; this.deviceStream = stream; // try and get the deviceId for the initial stream - let firstAllowedDeviceId; if (stream.getVideoTracks) { const videoTracks = stream.getVideoTracks(); if (videoTracks.length > 0 && videoTracks[0].getSettings) { @@ -228,7 +228,9 @@ class VideoPreview extends Component { firstAllowedDeviceId = trackSettings.deviceId; } } - + }).catch((error) => { + this.handleDeviceError('initial_device', error, 'getting initial device'); + }).finally(() => { navigator.mediaDevices.enumerateDevices().then((devices) => { const webcams = []; let initialDeviceId; @@ -272,13 +274,11 @@ class VideoPreview extends Component { }); } }).catch((error) => { - this.handleDeviceError('enumerate_error', error, 'enumerating devices'); + this.handleDeviceError('enumerate', error, 'enumerating devices'); }); - }).catch((error) => { - this.handleDeviceError('initial_device_error', error, 'getting initial device'); }); } catch (error) { - this.handleDeviceError('grabbing_error', error, 'grabbing initial video stream'); + this.handleDeviceError('grabbing', error, 'grabbing initial video stream'); } } else { // TODO: Add an error message when media is globablly disabled @@ -369,7 +369,7 @@ class VideoPreview extends Component { handleDeviceError(logCode, error, description) { logger.warn({ - logCode: `video_preview_${logCode}`, + logCode: `video_preview_${logCode}_error`, extraInfo: { errorName: error.name, errorMessage: error.message,