You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
iot/projects/IoT/IoT.Resources/wwwroot/demo.html

86 lines
2.8 KiB

<!DOCTYPE html>
<html>
<head>
<title>capturing video and video</title>
<style type="text/css">
html, body {
height: 100%;
width: 100%;
background: blue;
}
* {
margin: 0;
padding: 0;
}
#video {
margin: 0 auto;
width: 50%;
height: 50%;
background-color: #000000;
}
</style>
</head>
<body>
<div id="info">camera:</div>
<video id="video" autoplay="autoplay" controls="controls"></video>
<script src="lib/jquery/jquery.min.js"></script>
<script>
alert(1);
navigator.mediaDevices.enumerateDevices()
.then(function (devices) {
alert(devices);
//var arrayLength = devices.length;
//for (var i = 0; i < arrayLength; i++) {
// var tempDevice = devices[i];
// alert('<p>' + tempDevice.kind + '-' + tempDevice.facingMode + '-' + tempDevice.label + '</p>');
// //FOR EACH DEVICE, PUSH TO DEVICES LIST THOSE OF KIND VIDEOINPUT (cameras)
// //AND IF THE CAMERA HAS THE RIGHT FACEMODE ASSING IT TO "final"
// //if (tempDevice.kind == "videoinput") {
// // DEVICES.push(tempDevice);
// // if (tempDevice.facingMode == "environment" || tempDevice.label.indexOf("facing back") >= 0) { final = tempDevice; }
// //}
//}
});
</script>
<script type="text/javascript">
navigator
.mediaDevices
.getUserMedia({
video: {
//facingMode: 'user'
facingMode: 'environment'
},
audio: false
})
.then(function (mediaStream) {
var video = document.querySelector('video');
if ("srcObject" in video) {
video.srcObject = mediaStream
} else {
video.src = window.URL && window.URL.createObjectURL(mediaStream) || stream
}
video.onloadedmetadata = function (e) {
video.play();
};
})
.catch(function (error) {
alert(error)
});
//navigator
// .mediaDevices
// .enumerateDevices()
// .then(function (MediaDeviceInfo) {
// console.log(MediaDeviceInfo);
// })
//navigator
// .mediaDevices
// .getSupportedConstraints()
</script>
</body>
</html>