LoginSignup
1
0

More than 5 years have passed since last update.

メモ:Chrome でカメラを制御する

Posted at
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
</head>
<body>
<video id="video1" autoplay></video>
<script>
navigator.mediaDevices.getUserMedia({ video: true }).then(function (stream) {
    let video1 = document.getElementById('video1');
    video1.src = window.URL.createObjectURL(stream);
    video1.onloadedmetadata = function(e) {
        // 特別な処理をここで
        console.log(e);
    };
}).catch(function(e) { console.log(e.name); });
</script>
</body>
</html>

image.png
で、許可すればカメラの画像が画面に表示される。

実験したら、
image.png
で、セキュリティレベルを元に戻しておく。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0