From d43d2a4c5f983cbf67a97211b7934463e23a5089 Mon Sep 17 00:00:00 2001 From: Matt Sims Date: Wed, 20 Jun 2018 22:01:38 +0100 Subject: [PATCH] Fix QR code scanning in Safari (inc. iOS). --- public/assets/javascript/check_in.js | 15 ++++++++------- resources/views/ManageEvent/CheckIn.blade.php | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/public/assets/javascript/check_in.js b/public/assets/javascript/check_in.js index cdd50b8e..0ed0da41 100644 --- a/public/assets/javascript/check_in.js +++ b/public/assets/javascript/check_in.js @@ -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({ } } }); - diff --git a/resources/views/ManageEvent/CheckIn.blade.php b/resources/views/ManageEvent/CheckIn.blade.php index fb49928d..ea0d4f9a 100644 --- a/resources/views/ManageEvent/CheckIn.blade.php +++ b/resources/views/ManageEvent/CheckIn.blade.php @@ -122,7 +122,7 @@ - +