JSFiddle - React, Tailwind, and code Playground
by realhunts
HTML
<html>
<head>
<script>
var console = { log: function(msg) { div.innerHTML += "<p>" + msg + "</p>"; } };
var localstream;
if (navigator.mediaDevices.getUserMedia !== null) {
var options = {
video:true,
audio:false
};
navigator.webkitGetUserMedia(options, function(stream) {
vid.src = window.URL.createObjectURL(stream);
localstream = stream;
vid.play();
console.log("streaming");
}, function(e) {
console.log("background error : " + e.name);
});
}
function vidOff() {
//clearInterval(theDrawLoop);
//ExtensionData.vidStatus = 'off';
vid.pause();
vid.src = "";
localstream.getTracks()[0].stop();
console.log("Vid off");
}
</script>
</head>
<body>
<video id="vid" height="120" width="160" muted="muted" autoplay></video><br>
<button onclick="vidOff()">vidOff!</button><br>
<div id="div"></div>
</body>
</html>