From d0dabbda0c8a79fd0ef1b524b45412f0e6f22b05 Mon Sep 17 00:00:00 2001 From: "afiq.hamzah" Date: Tue, 3 Jan 2023 11:09:25 +0800 Subject: [PATCH] Update marhun camera implementation - add implementation to use camera with groupId if cameras with device label are unavailable --- public/js/marhun-photo-capture.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/public/js/marhun-photo-capture.js b/public/js/marhun-photo-capture.js index 23fc6412..eb0da36b 100644 --- a/public/js/marhun-photo-capture.js +++ b/public/js/marhun-photo-capture.js @@ -117,8 +117,18 @@ function marhunPhotoCapturerFactory(modal_selector) { } function composeConstraint(camera) { - var constraints = { deviceId: { exact: camera.deviceId } }; - return navigator.mediaDevices.getUserMedia({ video: constraints }); + + if(camera.deviceId !== ''){ + constraints = { deviceId: { exact: camera.deviceId } }; + return navigator.mediaDevices.getUserMedia({ video: constraints }); + } + + + if(camera.groupId !== ''){ + constraints= { groupId: { exact: camera.groupId } }; + return navigator.mediaDevices.getUserMedia({ video: constraints }); + } + } return getCameraList()