ParticipativeAfterMovie/index.js

24 lines
535 B
JavaScript
Raw Normal View History

2022-02-25 16:40:14 +01:00
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");
}