Skip to content

Instantly share code, notes, and snippets.

@adamabernathy
Last active December 12, 2017 16:08
Show Gist options
  • Save adamabernathy/814ea10a65adbb5f1ba9849d0f682f33 to your computer and use it in GitHub Desktop.
Save adamabernathy/814ea10a65adbb5f1ba9849d0f682f33 to your computer and use it in GitHub Desktop.
<html>
<head>
<style>
h1 {
text-align: center;
}
.container {
padding: 0 5em 5em 5em;
text-align: center;
}
.camera-display {
width: 75%;
height: 75%;
background-color: black;
}
</style>
</head>
<body>
<h1>I can see you</h1>
<div id="container" class="container">
<video autoplay="true" id="camera-display" class="camera-display">
</video>
</div>
</body>
<script>
const video = document.getElementById("camera-display");
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia || navigator.oGetUserMedia;
if (navigator.getUserMedia) {
navigator.getUserMedia({ video: true }, stream => {
video.src = window.URL.createObjectURL(stream);
}, err => {
alert('I can\'t spy on you!!');
console.warn(err);
});
}
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment