Hello, after looking it up on forums and tutorial I've managed to stream my webcam on an HTML video tag using the following code:
and I've been trying to do this but with the ABMVideo component from ABMaterial, since I need the video to show on a ABMModalSheet, but the only way I've managed to make the video stream on the ABMVideo component is by running the code above at the beginning of the ConnectPage method, and then calling retreiving the src from the video tag, but this isn't ideal, because that means the camera will be opened as soon as the page loads, not when the modal is shown. Is there any way to do this?
B4X:
var video = document.getElementById('video');
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.oGetUserMedia || navigator.msGetUserMedia;
If(navigator.getUserMedia){
navigator.getUserMedia({video: true}, streamWebCam, throwError);
}
function streamWebCam (stream) {
window.localStream = stream;
//NOT video.src = window.URL.createObjectURL(stream) since createObjectURL is deprecated
video.srcObject = stream;
video.play();
}
function throwError (e) {
alert(e.name);
}
and I've been trying to do this but with the ABMVideo component from ABMaterial, since I need the video to show on a ABMModalSheet, but the only way I've managed to make the video stream on the ABMVideo component is by running the code above at the beginning of the ConnectPage method, and then calling retreiving the src from the video tag, but this isn't ideal, because that means the camera will be opened as soon as the page loads, not when the modal is shown. Is there any way to do this?