Created
February 17, 2024 16:38
-
-
Save kraxarn/1996f8cf970f7e57e38c1cf88e7cc738 to your computer and use it in GitHub Desktop.
Webcam Relay
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Webcam Relay</title> | |
<style> | |
video { | |
width: 100%; | |
height: 100%; | |
} | |
</style> | |
</head> | |
<body> | |
<button id="start-capture">Start capture</button> | |
<video id="preview" controls></video> | |
<script> | |
const startCapture = document.getElementById("start-capture") | |
startCapture.addEventListener("click", async () => { | |
startCapture.style.display = "none" | |
let stream | |
try { | |
stream = await navigator.mediaDevices.getUserMedia({ | |
video: true, | |
audio: true, | |
}) | |
} catch (e) { | |
console.error(e) | |
} | |
const preview = document.getElementById("preview") | |
preview.srcObject = stream | |
preview.play() | |
}) | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment