test media capture

This commit is contained in:
Tropicananass 2022-02-25 16:40:14 +01:00
parent d0ab9fc114
commit 595679e869
3 changed files with 40 additions and 0 deletions

17
index.html Normal file
View File

@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Media recorder example</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<video autoplay></video>
<script src="index.js"></script>
</body>
</html>

23
index.js Normal file
View File

@ -0,0 +1,23 @@
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");
}

0
style.css Normal file
View File