📅  最后修改于: 2022-03-11 15:03:25.949000             🧑  作者: Mango
navigator.mediaDevices.getUserMedia(constraints) .then(function(stream) { var videoTracks = stream.getVideoTracks(); console.log('Got stream with constraints:', constraints); console.log('Using video device: ' + videoTracks[0].label); stream.onended = function() { console.log('Stream ended'); }; window.stream = stream; // make variable available to console video.srcObject = stream; }) .catch(function(error) { // ... }