-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpopup.js
More file actions
25 lines (23 loc) · 727 Bytes
/
Copy pathpopup.js
File metadata and controls
25 lines (23 loc) · 727 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
document.addEventListener('DOMContentLoaded', function () {
const requestCameraButton = document.getElementById('requestCamera');
const cameraPreview = document.getElementById('cameraPreview');
requestCameraButton.addEventListener('click', async () => {
const constraints = {
audio: true,
video: { width: 1280, height: 720 },
};
navigator.mediaDevices
.getUserMedia(constraints)
.then((mediaStream) => {
const video = document.querySelector("video");
video.srcObject = mediaStream;
video.onloadedmetadata = () => {
video.play();
};
})
.catch((err) => {
// always check for errors at the end.
console.error(`${err.name}: ${err.message}`);
});
});
});