Skip to content
Snippets Groups Projects
Commit d28ed1c4 authored by Steinwender, Tamara's avatar Steinwender, Tamara
Browse files

Try mobile supporting front and back camera

parent b61eb22b
No related branches found
No related tags found
No related merge requests found
Pipeline #13283 passed
...@@ -71,7 +71,7 @@ export class QrCodeScanner extends ScopedElementsMixin(DBPLitElement) { ...@@ -71,7 +71,7 @@ export class QrCodeScanner extends ScopedElementsMixin(DBPLitElement) {
devices.forEach(function (device) { devices.forEach(function (device) {
console.log(device.kind + ": " + device.label + console.log(device.kind + ": " + device.label +
" id = " + device.deviceId); " id = " + device.deviceId);
that._("#error").innerText += " | device.kind: " + device.kind + " id: " + device.deviceId + " label: " + device.label + " | "; // that._("#error").innerText += " | device.kind: " + device.kind + " id: " + device.deviceId + " label: " + device.label + " | ";
if (device.kind === 'videoinput') { if (device.kind === 'videoinput') {
let id = device.deviceId; let id = device.deviceId;
if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) { if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
...@@ -107,7 +107,7 @@ export class QrCodeScanner extends ScopedElementsMixin(DBPLitElement) { ...@@ -107,7 +107,7 @@ export class QrCodeScanner extends ScopedElementsMixin(DBPLitElement) {
const results = []; const results = [];
for (let i = 0; i !== sourceInfos.length; ++i) { for (let i = 0; i !== sourceInfos.length; ++i) {
const sourceInfo = sourceInfos[i]; const sourceInfo = sourceInfos[i];
that._("#error").innerText += " * kind: " + sourceInfo.kind + " id: " + sourceInfo.id + " label: " + sourceInfo.label + " * "; // that._("#error").innerText += " * kind: " + sourceInfo.kind + " id: " + sourceInfo.id + " label: " + sourceInfo.label + " * ";
if (sourceInfo.kind === 'video') { if (sourceInfo.kind === 'video') {
devices_map.set(sourceInfo.id ? sourceInfo.id : true, sourceInfo.label || i18n.t('camera') + (devices_map.size + 1)) devices_map.set(sourceInfo.id ? sourceInfo.id : true, sourceInfo.label || i18n.t('camera') + (devices_map.size + 1))
results.push({ results.push({
...@@ -164,11 +164,12 @@ export class QrCodeScanner extends ScopedElementsMixin(DBPLitElement) { ...@@ -164,11 +164,12 @@ export class QrCodeScanner extends ScopedElementsMixin(DBPLitElement) {
} }
const that = this; const that = this;
let constraint = { video: { deviceId: this._('#videoSource').val }}; let constraint = { video: { deviceId: this._('#videoSource').options[this._('#videoSource').selectedIndex].value } };
if ( (this._('#videoSource').val === 'environment') || (this._('#videoSource').val === 'user') ) { if ( (this._('#videoSource').options[this._('#videoSource').selectedIndex].value === 'environment') || (this._('#videoSource').options[this._('#videoSource').selectedIndex].value === 'user') ) {
constraint = { video: {facingMode: "environment"}}; constraint = { video: { facingMode: "environment" } };
} }
that._("#error").innerText += " constraint: " + JSON.stringify(constraint);
navigator.mediaDevices.getUserMedia(constraint).then(function(stream) { navigator.mediaDevices.getUserMedia(constraint).then(function(stream) {
video.srcObject = stream; video.srcObject = stream;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment