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

Add support to start immediatly the qr code scan

parent f07d13a4
No related branches found
No related tags found
No related merge requests found
Pipeline #13294 passed
...@@ -28,7 +28,7 @@ export class QrCodeScanner extends ScopedElementsMixin(DBPLitElement) { ...@@ -28,7 +28,7 @@ export class QrCodeScanner extends ScopedElementsMixin(DBPLitElement) {
this.stopScan = false; this.stopScan = false;
this.activeCamera = ''; this.activeCamera = '';
this.sourceChanged = false;
} }
static get scopedElements() { static get scopedElements() {
...@@ -53,6 +53,7 @@ export class QrCodeScanner extends ScopedElementsMixin(DBPLitElement) { ...@@ -53,6 +53,7 @@ export class QrCodeScanner extends ScopedElementsMixin(DBPLitElement) {
showOutput: { type: Boolean, attribute: 'show-output' }, showOutput: { type: Boolean, attribute: 'show-output' },
stopScan: { type: Boolean, attribute: 'stop-scan' }, stopScan: { type: Boolean, attribute: 'stop-scan' },
activeCamera: { type: String, attribute: false }, activeCamera: { type: String, attribute: false },
sourceChanged: { type: Boolean, attribute: false }
}; };
} }
...@@ -189,14 +190,15 @@ export class QrCodeScanner extends ScopedElementsMixin(DBPLitElement) { ...@@ -189,14 +190,15 @@ export class QrCodeScanner extends ScopedElementsMixin(DBPLitElement) {
}).catch((e) => { console.log(e); that.askPermission = true;}); }).catch((e) => { console.log(e); that.askPermission = true;});
function tick() { function tick() {
/* if (videoId !== that._('#videoSource').options[that._('#videoSource').selectedIndex].value) { if (that.sourceChanged) {
video.srcObject.getTracks().forEach(function(track) { video.srcObject.getTracks().forEach(function(track) {
track.stop(); track.stop();
console.log("Changed Media"); console.log("Changed Media");
}); });
that.sourceChanged = false;
that.qrCodeScannerInit(); that.qrCodeScannerInit();
return; return;
}*/ }
if (that.videoRunning === false) { if (that.videoRunning === false) {
video.srcObject.getTracks().forEach(function(track) { video.srcObject.getTracks().forEach(function(track) {
track.stop(); track.stop();
...@@ -252,6 +254,11 @@ export class QrCodeScanner extends ScopedElementsMixin(DBPLitElement) { ...@@ -252,6 +254,11 @@ export class QrCodeScanner extends ScopedElementsMixin(DBPLitElement) {
} }
} }
updateSource(e) {
this.activeCamera = e.srcElement.value;
this.sourceChanged = true;
}
stopScanning() { stopScanning() {
this.askPermission = false; this.askPermission = false;
this.videoRunning = false; this.videoRunning = false;
...@@ -285,6 +292,7 @@ export class QrCodeScanner extends ScopedElementsMixin(DBPLitElement) { ...@@ -285,6 +292,7 @@ export class QrCodeScanner extends ScopedElementsMixin(DBPLitElement) {
#canvas { #canvas {
width: 100%; width: 100%;
margin-top: 2rem;
} }
#output { #output {
...@@ -317,7 +325,7 @@ export class QrCodeScanner extends ScopedElementsMixin(DBPLitElement) { ...@@ -317,7 +325,7 @@ export class QrCodeScanner extends ScopedElementsMixin(DBPLitElement) {
font-size: inherit; font-size: inherit;
} }
select:not(.select)#videoSource{ select:not(.select)#videoSource{
background-size: 15%; background-size: auto 45%;
} }
.border{ .border{
...@@ -343,20 +351,20 @@ export class QrCodeScanner extends ScopedElementsMixin(DBPLitElement) { ...@@ -343,20 +351,20 @@ export class QrCodeScanner extends ScopedElementsMixin(DBPLitElement) {
<button class="start button is-primary ${classMap({hidden: this.videoRunning})}" @click="${() => this.qrCodeScannerInit(this)}" title="${i18n.t('start-scan')}">${i18n.t('start-scan')}</button> <button class="start button is-primary ${classMap({hidden: this.videoRunning})}" @click="${() => this.qrCodeScannerInit(this)}" title="${i18n.t('start-scan')}">${i18n.t('start-scan')}</button>
<button class="stop button is-primary ${classMap({hidden: !this.videoRunning})}" @click="${() => this.stopScanning()}" title="${i18n.t('stop-scan')}">${i18n.t('stop-scan')}</button> <button class="stop button is-primary ${classMap({hidden: !this.videoRunning})}" @click="${() => this.stopScanning()}" title="${i18n.t('stop-scan')}">${i18n.t('stop-scan')}</button>
<select id="videoSource" class="button"></select> <select id="videoSource" class="button" @change=${this.updateSource}></select>
</div> </div>
<div id="loadingMessage" class="border ${classMap({hidden: !this.askPermission})}"> <div id="loadingMessage" class=" ${classMap({hidden: !this.askPermission})}">
<div class="wrapper-msg"> <div class="wrapper-msg">
<dbp-mini-spinner class="spinner ${classMap({hidden: !this.loading})}"></dbp-mini-spinner> <dbp-mini-spinner class="spinner ${classMap({hidden: !this.loading})}"></dbp-mini-spinner>
<div class="loadingMsg">${i18n.t('no-camera-access')}</div> <div class="loadingMsg">${i18n.t('no-camera-access')}</div>
</div> </div>
</div> </div>
<canvas id="canvas" hidden class="border"></canvas> <canvas id="canvas" hidden class=""></canvas>
<pre id="error"></pre> <pre id="error"></pre>
<div id="output" hidden class="border ${classMap({hidden: !this.showOutput})}"> <div id="output" hidden class=" ${classMap({hidden: !this.showOutput})}">
<div id="outputMessage">${i18n.t('no-qr-detectede')}</div> <div id="outputMessage">${i18n.t('no-qr-detectede')}</div>
<div hidden><b>${i18n.t('data')}:</b> <span id="outputData"></span></div> <div hidden><b>${i18n.t('data')}:</b> <span id="outputData"></span></div>
</div> </div>
......
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