fixed cameraIndex handling

pull/97/head
Matthias Jauernig 9 years ago
parent bd429ec362
commit 0c5b9dbba5

@ -84,15 +84,16 @@ function normalizeConstraints(config, cb) {
if ( typeof MediaStreamTrack !== 'undefined' && typeof MediaStreamTrack.getSources !== 'undefined') { if ( typeof MediaStreamTrack !== 'undefined' && typeof MediaStreamTrack.getSources !== 'undefined') {
MediaStreamTrack.getSources(function(sourceInfos) { MediaStreamTrack.getSources(function(sourceInfos) {
var videoSourceId, facingDetected, videoIndex = 0; var videoSourceId, videoIndex = 0;
for (var i = 0; i < sourceInfos.length; ++i) { for (var i = 0; i < sourceInfos.length; ++i) {
var sourceInfo = sourceInfos[i]; var sourceInfo = sourceInfos[i];
if (sourceInfo.kind === "video" && !facingDetected) { if (sourceInfo.kind === "video") {
if (sourceInfo.facing === videoConstraints.facing) { 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; videoSourceId = sourceInfo.id;
} }

Loading…
Cancel
Save