Skip to content

Commit

Permalink
Fixed the work around for incomplete implementations of facingMode.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rob Manson authored and robman committed Dec 1, 2016
1 parent d4da2e7 commit dbe16b6
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions js/awe-standard.js
Original file line number Diff line number Diff line change
Expand Up @@ -1430,20 +1430,21 @@
}

if (navigator.mediaDevices && navigator.mediaDevices.enumerateDevices) {

navigator.mediaDevices.enumerateDevices()
.then(function(devices) {
var selected_source = null;
var last_videoinput_source = null;
devices.forEach(function(device) {
if (device.kind === 'videoinput') {
if (!selected_source) {
selected_source = device.deviceId;
}
else if (device.label.indexOf(' back') > -1) {
if (BODY.facing_mode === 'environment' && device.label.indexOf('back') !== -1) {
selected_source = device.deviceId;
}
last_videoinput_source = device.deviceId;
}
});
if ((!selected_source || BODY.facing_mode === 'environment') && last_videoinput_source) {
selected_source = last_videoinput_source;
}
go(selected_source);
})
.catch(function(err) {
Expand Down

0 comments on commit dbe16b6

Please sign in to comment.