I want to create webview app that captures photo from video element. It works just fine in browser, but I can't start video in webview after page is loaded
function initCamera(front = true) {
cameraFrontStatus = front;
var video = document.getElementsByClassName('camera')[0];
if (navigator.mediaDevices.getUserMedia) {
if(front == true) {
var vgaConstraints = {
video: {
width: { ideal: 1080 },
height: { ideal: 1080 },
facingMode: 'environment'
},
};
} else {
var vgaConstraints = {
video: {
width: { ideal: 1080 },
height: { ideal: 1080 },
},
};
}
navigator.mediaDevices.getUserMedia(vgaConstraints).then((stream) => {
video.srcObject = stream;
}).catch(function (err0r) {
console.log("Something went wrong!");
});
}
}
codepen example: https://codepen.io/IGentlich/pen/KKZKoOY
Is there any possible way, to start video with stream as src onload in webview?