function hasGetUserMedia() { return !!(navigator.mediaDevices && navigator.mediaDevices.getUserMedia); } function getDeviceAccess() { const constraints = { video: true, audio: true }; const video = document.querySelector("video"); // todo avoid to play sound (only display video feedback) navigator.mediaDevices.getUserMedia(constraints).then((stream) => { video.srcObject = stream; }); } if (hasGetUserMedia()) { getDeviceAccess() } else { alert("getUserMedia() is not supported by your browser"); }