获取浏览器摄像头,麦克风列表
关于谷歌浏览器:Javascript:获取浏览器的选定麦克风名称 | 码农家园 (codenong.com)
获取
navigator.mediaDevices.enumerateDevices() .then(function(devices) { devices.forEach(function(device) { //audioinput videoinput(视频) audiooutput(音频) console.log('设备3:'+device.kind + ": " + device.label + " id = " + device.deviceId); });
设置选择哪个摄像头
navigator.mediaDevices.getUserMedia({ audio: {deviceId:deviceId}, video: false, }).then(function (stream) { getAudioSuccess(stream); })["catch"](function (e) { getAudioFail(e); });
参考:MediaDevices.getUserMedia() - Web API 接口参考 | MDN (mozilla.org)