예전에 본 것 같긴한데 해본적은 없는 것 같아서 검색
[링크 : https://velog.io/@davelee/browser에서-webcam-이용하기]
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}`); }); |
[링크 : https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia]
Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers. navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia; if (navigator.getUserMedia) { navigator.getUserMedia( { audio: true, video: { width: 1280, height: 720 } }, (stream) => { const video = document.querySelector("video"); video.srcObject = stream; video.onloadedmetadata = (e) => { video.play(); }; }, (err) => { console.error(`The following error occurred: ${err.name}`); }, ); } else { console.log("getUserMedia not supported"); } |
[링크 : https://developer.mozilla.org/en-US/docs/Web/API/Navigator/getUserMedia] deprecated
'Programming > web 관련' 카테고리의 다른 글
webgl + three.js를 이용한 GL 공부하기 (feat 클로드) (0) | 2024.10.18 |
---|---|
three.js (0) | 2024.09.19 |
XMLHttpRequest 가로채기 (0) | 2024.07.19 |
web worker (0) | 2024.07.19 |
mirage.js - api mockup (0) | 2024.07.19 |