!7 cmodule WebCamDemo > DynPrintLog { !include #1029545 // API for Eleu O html(IWebRequest request) { //ret "URI: " + request.uri(); ret hsansserif() + hfullcenter(p("WebCam Preview") + hfulltag video("", autoplay := true, id := "webcamPreview", style := "width: 600px; height: 400px; border: 5px solid red;") + p("Snapshot" + hbutton("Grab", onclick := "snapshot()") + hfulltag canvas("", id := "snapshotCanvas", style := "width: 300px; height: 200px; border: 3px solid green;") ) + hscript([[ var video = document.querySelector("#webcamPreview"); if (navigator.mediaDevices.getUserMedia) { navigator.mediaDevices.getUserMedia({ video: true }) .then(function (stream) { video.srcObject = stream; }) .catch(function (err0r) { console.log("Something went wrong: " + err0r); }); }; function snapshot() { var canvas = document.getElementById("snapshotCanvas"); canvas.getContext("2d") .drawImage(video, 0, 0, canvas.width, canvas.height); } ]]); } }