Merge branch 'afiqhamzah-add-marhun-camera-capabilities-on-firefox' into 'main'

Add marhun camera capabilities on firefox

See merge request online-sistem1/lelong!377
This commit is contained in:
Muhamad Amir Hassan Hamzan
2023-02-05 03:09:47 +00:00
4 changed files with 28 additions and 13 deletions
+3 -2
View File
@@ -299,8 +299,9 @@ PUSHER_APP_CLUSTER=mt1
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
MARHUN_CAMERAS = "Doccamera"
MARHUN_CAMERAS_CHROME = "Doccamera"
MARHUN_CAMERAS_FIREFOX = "jSsq68fCLg2guCV2FaFzvXXiKBqbPA25DaQAWWotfqY="
WABOT_API=https://md.wabot.my/api/send.php
WABOT_INSTANCES_ID=63C26B7AAD21A
WABOT_TOKEN_KEYS=cbee7e95cf3ffbfa0531d5fddfd44f87
WABOT_TOKEN_KEYS=cbee7e95cf3ffbfa0531d5fddfd44f87
+2 -3
View File
@@ -1,7 +1,6 @@
<?php
return [
'marhun_cameras' => array_map(fn ($camera_label) => trim($camera_label), explode(',', env('MARHUN_CAMERAS'))) ?? 'Doccamera'
'marhun_cameras_chrome' => array_map(fn ($camera_label) => trim($camera_label), explode(',', env('MARHUN_CAMERAS_CHROME'))) ?? 'Doccamera',
'marhun_cameras_firefox' => array_map(fn ($camera_label) => trim($camera_label), explode(',', env('MARHUN_CAMERAS_FIREFOX'))) ?? "jSsq68fCLg2guCV2FaFzvXXiKBqbPA25DaQAWWotfqY="
];
+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);
+4 -2
View File
@@ -1,12 +1,14 @@
@extends('layouts.app')
@push('additional_scripts')
<script src="{{ asset('js/marhun-photo-capture.js') }}"></script>
<script src="https://cdn.jsdelivr.net/npm/image-capture@0.4.0/lib/imagecapture.min.js"></script>
<script src="{{ asset('js/marhun-photo-capture.js').'?'.rand(1,1000) }}"></script>
<script src="{{ asset('js/marhun-photo-capture-reload-https.js') }}"></script>
<script src="{{ asset('js/marhun-photo-capture-debugger.js') }}"></script>
<script src="{{ asset('js/marhun-photo-viewer.js') }}"></script>
<script>
var marhun_camera_config = @json(config('marhun_camera.marhun_cameras'));
var marhun_camera_config_chrome = @json(config('marhun_camera.marhun_cameras_chrome'));
var marhun_camera_config_firefox= @json(config('marhun_camera.marhun_cameras_firefox'));
let modalOverallPhotoCapture = new marhunPhotoCapturerFactory('#modaloverallphoto-capture');
let modalOverallPhotoCaptureUpdate = new marhunPhotoCapturerFactory('#modaloverallphoto-capture-update');
let modalOverallPhotoCapturePerMarhun = new marhunPhotoCapturerFactory('#modalpermarhunphoto-capture');