<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<video id="video"></video>
<a href="https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia">详细配置点击查看</a>
</body>
<script>
navigator.mediaDevices.getUserMedia({
video:{//分辨率 1280*720
width: 1280,
height: 720,
facingMode: 'user' // user 前置摄像头 {exact: 'environment'}
}
}).then( (stream) =>{
video.src = URL.createObjectURL(stream);
video.play();
});
</script>
</html>