1 (function () { 2 3 var video = document.createElement("video"); 4 video.autoplay="autoplay"; 5 document.body.appendChild(video); 6 7 function init() { 8 navigator.mediaDevices.getUserMedia({ 9 audio: false, video: true 10 }).then(function (result) { 11 video.srcObject = result; 12 }).catch(function (error) { 13 console.log(error); 14 }) 15 } 16 17 init(); 18 })();