Skip to content

Instantly share code, notes, and snippets.

@kraxarn
Created February 17, 2024 16:38
Show Gist options
  • Save kraxarn/1996f8cf970f7e57e38c1cf88e7cc738 to your computer and use it in GitHub Desktop.
Save kraxarn/1996f8cf970f7e57e38c1cf88e7cc738 to your computer and use it in GitHub Desktop.
Webcam Relay
<!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