1<!DOCTYPE html>
2<html>
3<body>
4 <div id="container">
5 <video autoplay="true"></video>
6 </div>
7 <button class="btn" onclick="startWebCam()">Start</button>
8 <script type="text/javascript">
9 var video = document.querySelector("video");
10 function startWebCam() {
11 if (navigator.mediaDevices.getUserMedia) {
12 navigator.mediaDevices.getUserMedia({ video: true })
13 .then(function (stream) {
14 video.srcObject = stream;
15 })
16 .catch(function (err0r) {
17 console.log("Something went wrong!");
18 });
19 }
20 }
21 startWebCam();
22 </script>
23</body>
24</html>