Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Videokonferenz ganz allein
<html>
<head>
<meta charset="utf-8">
<title>Meine Videokonferenz mit mir selbst</title>
<style type="text/css">
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: Helvetica, Arial, sans-serif;
}
body {
text-align: center;
}
#conference {
margin: 30px auto;
border: 10px darkgray solid;
border-radius: 5px;
display: inline-block;
}
#webcam {
width: 640px;
height: 480px;
background-color: lightgray;
}
div.error {
background-color: red;
color: white;
padding: 10px;
width: 640px;
font-weight: bold;
}
</style>
</head>
<body>
<div id="conference">
<h1>Meine Videokonferenz</h1>
<video autoplay="true" id="webcam"></video>
</div>
<script type="text/javascript">
var webcam = document.querySelector("#webcam");
if (navigator.mediaDevices.getUserMedia) {
navigator
.mediaDevices.getUserMedia({ video: true })
.then(function (stream) {
webcam.srcObject = stream;
})
.catch(function (e) {
var error = document.createElement('div');
error.setAttribute('class', 'error');
error.innerHTML = e.message;
webcam.parentNode.insertBefore(error, webcam);
});
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment