I have a web application that uses getUserMedia to show a camera inside it. So far this is working fine, but i'm having a problem when i open a second tab while the stream is getting used in another one (the camera doesn´t render where its supposed to). I tried using getVideoTracks to check if its enabled and his readyState is 'live' as suggested on How to check with JavaScript that webcam is being used in Chrome but it doesnt do the trick. Is there another way to do this? My code:
if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
navigator.mediaDevices.getUserMedia({video: {
facingMode: this.cameraMode,
width: { ideal: 4096}, height: { ideal: 2160}
}}).then(stream => {
//some code here
}, error => {
console.error(error);
});
}