| 1234567891011121314151617181920212223242526272829303132 |
- <html>
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
- <title>getUserMedia test</title>
- </head>
- <body>
- <video id="video" autoplay="true" playsinline></video>
- <script>
- var video = document.querySelector("#video");
- if ((navigator.mediaDevices && navigator.mediaDevices.getUserMedia)) {
- navigator.mediaDevices.getUserMedia({
- video: true,
- audio: false
- })
- .then(function (stream) {
- video.srcObject = stream;
- video.play();
- })
- .catch(function (err) {
- console.log("你拒绝使用相机:" + err);
- });
- } else {
- console.log("您的浏览器不支持影像功能");
- }
- </script>
- </body>
- </html>
|