From 99a6df9d7cb3d5ebe44476efb2982e02819f8dfa Mon Sep 17 00:00:00 2001 From: "afiq.hamzah" Date: Tue, 3 Jan 2023 11:06:36 +0800 Subject: [PATCH 1/2] Update marhun camera debugger - Fix debugger by showing groupId of camera if the camera label is not available --- public/js/marhun-photo-capture-debugger.js | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/public/js/marhun-photo-capture-debugger.js b/public/js/marhun-photo-capture-debugger.js index 7ba6bcea..8a4e9bdc 100644 --- a/public/js/marhun-photo-capture-debugger.js +++ b/public/js/marhun-photo-capture-debugger.js @@ -13,9 +13,26 @@ function marhunPhotoCapturerDebugger() { const generateCameraListing = (cameras) => { let title = "Available cameras: "; - let content = cameras.map((camera, index) => { + let mapCameraWithDeviceId = (index, camera) => { index = index + 1; - return `${index}. ${camera.label}\n`; + return `${index}. deviceLabel : ${camera.label}\n`; + } + + let mapCameraWithGroupId = (index, camera) => { + index = index + 1; + return `${index}. groupId : ${camera.groupId}\n`; + } + + let content = cameras.map((camera, index) => { + if(camera.deviceId !== ''){ + return mapCameraWithDeviceId(index, camera); + } + + if(camera.groupId !== ''){ + return mapCameraWithGroupId(index, camera); + } + + }); return `${title}\n${content.join('')}`; From d0dabbda0c8a79fd0ef1b524b45412f0e6f22b05 Mon Sep 17 00:00:00 2001 From: "afiq.hamzah" Date: Tue, 3 Jan 2023 11:09:25 +0800 Subject: [PATCH 2/2] 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()