Merge branch 'afiqhamzah/fix/ask_camera_permission_before_use_camera' into 'main'

Fix camera not displaying image by asking to use camera before using it

See merge request online-sistem1/lelong!438
This commit is contained in:
Muhamad Amir Hassan Hamzan
2023-04-13 04:22:25 +00:00
2 changed files with 10 additions and 3 deletions
+2
View File
@@ -38,6 +38,8 @@ function marhunPhotoCapturerDebugger() {
return `${title}\n${content.join('')}`;
};
navigator.mediaDevices.getUserMedia({audio: true, video: true});
navigator.mediaDevices.enumerateDevices()
.then(devices => devices.filter(x => x.kind === 'videoinput'))
.then(devices => devices.map(device => {
+8 -3
View File
@@ -75,8 +75,13 @@ function marhunPhotoCapturerFactory(modal_selector) {
getCamera: function () {
function getCameraList() {
return navigator.mediaDevices.enumerateDevices()
.then(devices => devices.filter(x => x.kind === 'videoinput'))
let getUserMedia = () => navigator.mediaDevices.getUserMedia({audio: true, video: true});
let enumerateDevices = () => navigator.mediaDevices.enumerateDevices()
.then(devices => devices.filter(x => x.kind === 'videoinput'));
getUserMedia();
return enumerateDevices();
}
function selectNearWorkingCamera(listOfCameras) {
@@ -134,7 +139,7 @@ function marhunPhotoCapturerFactory(modal_selector) {
function composeConstraint(camera) {
let constraints = {
let constraints = {
width: {min: 640, ideal: 1920},
height: {min: 400, ideal: 1080},
aspectRatio: {ideal: 1.7777777778},