Fix QR code scanning in Safari (inc. iOS).

This commit is contained in:
Matt Sims 2018-06-20 22:01:38 +01:00
parent ffb12f7a3b
commit d43d2a4c5f
2 changed files with 9 additions and 8 deletions

View File

@ -111,19 +111,21 @@ var checkinApp = new Vue({
qrcode.callback = this.QrCheckin;
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia;
navigator.getUserMedia({video: true, audio: false}, function (stream) {
navigator.getUserMedia({
video: {
facingMode: 'environment'
},
audio: false
}, function (stream) {
that.stream = stream;
console.log(stream);
if (that.videoElement.mozSrcObject !== undefined) { // works on firefox now
that.videoElement.mozSrcObject = stream;
} else if(window.URL) { // and chrome, but must use https
var objectURL = window.URL.createObjectURL(stream);
that.videoElement.src = objectURL || stream;
that.videoElement.srcObject = stream;
};
that.videoElement.play();
}, function () { /* error*/
alert(lang("checkin_init_error"));
});
@ -170,4 +172,3 @@ var checkinApp = new Vue({
}
}
});

View File

@ -122,7 +122,7 @@
<a @click="closeScanner" class="closeScanner" href="javascript:void(0);">
<i class="ico-close"></i>
</a>
<video id="scannerVideo" autoplay></video>
<video id="scannerVideo" playsinline autoplay></video>
<div class="scannerButtons">
<a @click="initScanner" v-show="!isScanning" href="javascript:void(0);">