我尝试在Ubuntu 16.04上的Mozilla Firefox v50.1.0中运行此脚本以检测音频设备。[1]
navigator.mediaDevices.enumerateDevices()
.then(function(devices) {
devices.forEach(function(device) {
console.log(device.kind + ": " + device.label +
" id = " + device.deviceId);
});
})
.catch(function(err) {
console.log(err.name + ": " + err.message);
});
它仅检测输入设备,但不检测输出。在Chrome和Opera中工作正常,但在Firefox中不起作用。
顺便说一下,我需要在Firefox的about:config中手动添加我的页面域名到media.getusermedia.screensharing.allowed_domains,才能获得弹出窗口提示允许共享我的设备。为什么需要这样做呢?