Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> JavaScript

Không thể chụp ảnh từ webcam dùng HTML5 khi tải trang đầu tiên


Bạn cần thử sau để chụp ảnh từ webcam dùng HTML5:

Khai báo biến

var streaming = false,    video = document.querySelector('#video'), canvas = document.querySelector('#canvas'),    photo = document.querySelector('#photo'),    startbutton = document.querySelector('#startbutton'),    width = 320,    height = 0;

Dùng getUserMedia

navigator.getMedia = ( navigator.getUserMedia ||                 navigator.webkitGetUserMedia ||                   navigator.mozGetUserMedia ||                    navigator.msGetUserMedia);