Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Capture Video and Audio in Single Browser via WebRTC Media API
<!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Capture Video and Audio</title>
<script src=""></script>
<video autoplay></video>
audio: true,
video: true
.then((stream) => {
document.querySelector("p").textContent = "Connected";
console.log("connected audio");
let video = document.querySelector("video");
video.srcObject = stream;;
.catch((e) => {
document.querySelector("p").textContent = "Not Connected";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment