Add marhun camera capabilities on firefox

This commit is contained in:
afiq.hamzah
2023-02-05 09:43:05 +08:00
parent f78a27fa5c
commit 1f62281709
4 changed files with 28 additions and 13 deletions
+19 -6
View File
@@ -98,12 +98,20 @@ function marhunPhotoCapturerFactory(modal_selector) {
});
const filtered = available_cameras.filter(camera => {
return marhun_camera_config.includes(camera.label);
const filteredCameraChrome = available_cameras.filter(camera => {
return marhun_camera_config_chrome.includes(camera.label);
})
const filteredCameraFirefox = available_cameras.filter(camera => {
return marhun_camera_config_firefox.includes(camera.deviceId);
});
if(filteredCameraFirefox.length > 0){
return filteredCameraFirefox.at(-1);
}
// Get the first available priority referencing to env
return filtered.at(-1);
return filteredCameraChrome.at(-1);
}
function selectCamera(listOfCameras) {
@@ -118,14 +126,20 @@ function marhunPhotoCapturerFactory(modal_selector) {
function composeConstraint(camera) {
let constraints = {
width: {min: 640, ideal: 1920},
height: {min: 400, ideal: 1080},
aspectRatio: {ideal: 1.7777777778},
};
if(camera.deviceId !== ''){
constraints = { deviceId: { exact: camera.deviceId } };
constraints.deviceId = { exact: camera.deviceId };
return navigator.mediaDevices.getUserMedia({ video: constraints });
}
if(camera.groupId !== ''){
constraints= { groupId: { exact: camera.groupId } };
constraints.groupId = { exact: camera.groudId };
return navigator.mediaDevices.getUserMedia({ video: constraints });
}
@@ -140,7 +154,6 @@ function marhunPhotoCapturerFactory(modal_selector) {
initiateTakeMarhunPhoto: function () {
if ('mediaDevices' in navigator && navigator.mediaDevices.getUserMedia) {
function showCaptureMarhunModal() {
let modal = document.querySelector(modal_selector);