From 0c5b9dbba5a89f0dd08c7009d4ddb43e495b9b60 Mon Sep 17 00:00:00 2001 From: Matthias Jauernig Date: Wed, 23 Mar 2016 22:50:23 +0100 Subject: [PATCH] fixed cameraIndex handling --- src/input/camera_access.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/input/camera_access.js b/src/input/camera_access.js index 5d7ef74..5bf0e26 100644 --- a/src/input/camera_access.js +++ b/src/input/camera_access.js @@ -84,15 +84,16 @@ function normalizeConstraints(config, cb) { if ( typeof MediaStreamTrack !== 'undefined' && typeof MediaStreamTrack.getSources !== 'undefined') { MediaStreamTrack.getSources(function(sourceInfos) { - var videoSourceId, facingDetected, videoIndex = 0; + var videoSourceId, videoIndex = 0; for (var i = 0; i < sourceInfos.length; ++i) { var sourceInfo = sourceInfos[i]; - if (sourceInfo.kind === "video" && !facingDetected) { + if (sourceInfo.kind === "video") { if (sourceInfo.facing === videoConstraints.facing) { - facingDetected = true; + videoSourceId = sourceInfo.id; + break; } - if (!config.cameraIndex || config.cameraIndex <= videoIndex) { + if (videoConstraints.cameraIndex === 'undefined' || videoConstraints.cameraIndex >= videoIndex) { videoSourceId = sourceInfo.id; }