diff --git a/src/webrtc-media-provider.js b/src/webrtc-media-provider.js index 869f3f32..2d68eed2 100644 --- a/src/webrtc-media-provider.js +++ b/src/webrtc-media-provider.js @@ -1717,12 +1717,13 @@ const getMobileDevices = async function (kind, deviceConstraints = null) { if (stream.getVideoTracks().length > 0) { deviceId = stream.getVideoTracks()[0].getSettings().deviceId; } - stream.getTracks().forEach((track) => { + stream.getTracks().forEach((track) => { track.stop(); }); } } catch (error) { logger.error(LOG_PREFIX, "Can't get device access with video constraints " + JSON.stringify(constraints.video) + ", error " + error); + throw error; } return deviceId; } @@ -1752,6 +1753,11 @@ const getMobileDevices = async function (kind, deviceConstraints = null) { } } catch (error) { logger.error(LOG_PREFIX, "Can't get device access with constraints " + JSON.stringify(constraints) + ", error " + error); + throw error; + } + + if (!list) { + throw new Error("No media devices found"); } return list; @@ -1894,4 +1900,4 @@ module.exports = { getAudioSourceDevice: getAudioSourceDevice, getCacheInstance: getCacheInstance, getVideoElement: getVideoElement -}; \ No newline at end of file +};