function captureLocalMedia() {
if (navigator.mediaDevices.getUserMedia) {
console.log('最新的标准API',navigator.mediaDevices.getUserMedia);
navigator.mediaDevices.getUserMedia(constraints).then(gotLocalMedia).catch(function(e){
console.log('getUserMedia() error: ' + e);});
} else if (navigator.webkitGetUserMedia) {
console.log('webkit核心浏览器');
navigator.webkitGetUserMedia(constraints, gotLocalMedia, function(e){
console.log('getUserMedia() error: ' + e.name);})
} else if (navigator.mozGetUserMedia) {
console.log('firfox浏览器');
navigator.mozGetUserMedia(constraints, gotLocalMedia, function(e){
console.log('getUserMedia() error: ' + e.name);});
} else if (navigator.getUserMedia) {
console.log('旧版API');
navigator.getUserMedia(constraints, gotLocalMedia, function(e){
console.log('getUserMedia() error: ' + e.name);});
}
}
获取浏览器摄像头和麦克风,各大浏览器的兼容问题
最新推荐文章于 2023-12-07 17:41:06 发布