WebRTC 打开摄像头:https://www.cnblogs.com/wangrong1/p/12579618.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>采集本地音视频流</title>
<style>
a { text-decoration:none; }
video { border:1px solid gray; margin:0 auto;}
</style>
</head>
<body>
<h1 align="center"><a href="https://www.cnblogs.com/wangrong1/p/12579618.html" target="_blank">采集本地音视频流</a></h1>
<div align="center">
<video autoplay id="stream"></video>
</div>
<script>
video = document.getElementById('stream');
var constraints = {
video: true,
audio: true
}
//判断浏览器支不支持getUserMedia
if (!navigator.mediaDevices || !navigator.mediaDevices.getUserMedia) {
console.log("您的浏览器不支持getUserMedia")
} else {
navigator.mediaDevices.getUserMedia(constraints)
.then(function(stream) {
video.srcObject = stream;
}).catch(function(err) {
console.log(err);
})
}
</script>
</body>
</html>