Fix camera not displaying image by asking to use camera before using it
This commit is contained in:
+2
@@ -38,6 +38,8 @@ function marhunPhotoCapturerDebugger() {
|
|||||||
return `${title}\n${content.join('')}`;
|
return `${title}\n${content.join('')}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
navigator.mediaDevices.getUserMedia({audio: true, video: true});
|
||||||
|
|
||||||
navigator.mediaDevices.enumerateDevices()
|
navigator.mediaDevices.enumerateDevices()
|
||||||
.then(devices => devices.filter(x => x.kind === 'videoinput'))
|
.then(devices => devices.filter(x => x.kind === 'videoinput'))
|
||||||
.then(devices => devices.map(device => {
|
.then(devices => devices.map(device => {
|
||||||
|
|||||||
Vendored
+8
-3
@@ -75,8 +75,13 @@ function marhunPhotoCapturerFactory(modal_selector) {
|
|||||||
|
|
||||||
getCamera: function () {
|
getCamera: function () {
|
||||||
function getCameraList() {
|
function getCameraList() {
|
||||||
return navigator.mediaDevices.enumerateDevices()
|
let getUserMedia = () => navigator.mediaDevices.getUserMedia({audio: true, video: true});
|
||||||
.then(devices => devices.filter(x => x.kind === 'videoinput'))
|
|
||||||
|
let enumerateDevices = () => navigator.mediaDevices.enumerateDevices()
|
||||||
|
.then(devices => devices.filter(x => x.kind === 'videoinput'));
|
||||||
|
getUserMedia();
|
||||||
|
|
||||||
|
return enumerateDevices();
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectNearWorkingCamera(listOfCameras) {
|
function selectNearWorkingCamera(listOfCameras) {
|
||||||
@@ -134,7 +139,7 @@ function marhunPhotoCapturerFactory(modal_selector) {
|
|||||||
|
|
||||||
function composeConstraint(camera) {
|
function composeConstraint(camera) {
|
||||||
|
|
||||||
let constraints = {
|
let constraints = {
|
||||||
width: {min: 640, ideal: 1920},
|
width: {min: 640, ideal: 1920},
|
||||||
height: {min: 400, ideal: 1080},
|
height: {min: 400, ideal: 1080},
|
||||||
aspectRatio: {ideal: 1.7777777778},
|
aspectRatio: {ideal: 1.7777777778},
|
||||||
|
|||||||
Reference in New Issue
Block a user