From 82e631a5d1e0bb56223ca483ef0d71ddf193250a Mon Sep 17 00:00:00 2001 From: Afiq Hamzah Date: Thu, 25 May 2023 13:49:47 +0800 Subject: [PATCH] Fix to be usable to firefox - Firefox can only detect lower resolution capability of camera, adding the min resolution in the camera constraints enables it to work in firefox --- public/js/marhun-photo-capture.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/public/js/marhun-photo-capture.js b/public/js/marhun-photo-capture.js index 32d01223..6923f693 100644 --- a/public/js/marhun-photo-capture.js +++ b/public/js/marhun-photo-capture.js @@ -95,7 +95,6 @@ function marhunPhotoCapturerFactory(modal_selector) { let enumerateDevices = () => navigator.mediaDevices.enumerateDevices() .then(devices => devices.filter(x => x.kind === 'videoinput')) - .then(x => {console.log; return x;}); getUserMedia(); @@ -159,8 +158,9 @@ function marhunPhotoCapturerFactory(modal_selector) { function composeConstraint(camera) { let constraints = { - width: { exact: 3200 }, - height: { exact: 1800 }, + width: { min: 1280, max: 3200 }, + height: { min: 720, max: 1800 }, + aspectRatio: {exact: 1.7777777778}, }; if (camera.deviceId !== '') { @@ -198,6 +198,7 @@ function marhunPhotoCapturerFactory(modal_selector) { } function streamCameraView(stream) { + console.log(stream.getVideoTracks()[0].getSettings()) let modal = document.querySelector(modal_selector); let videoTagPreview = modal.querySelector('.video-tag-overallmarhun.video-preview'); let videoTagData = modal.querySelector('.video-tag-overallmarhun.video-data');