gpt4 book ai didi

html - Firefox 不支持 mediastreamtrack.getsources,如何做等效的

转载 作者:太空狗 更新时间:2023-10-29 15:19:20 26 4
gpt4 key购买 nike

是否有等效的方法来获取连接到 PC 的视频设备列表?除了内置网络摄像头连接外,我还有一个外部网络摄像头连接。

mediastreamtrack.getsources 在 chrome 中工作,但 firefox 报告“类型错误:MediaStreamTrack.getSources 不是函数”。我正在运行 firefox 版本 25.0.1

谢谢!

最佳答案

请使用下面提到的代码。它工作正常,提供所有音频和视频设备列表。

navigator.mediaDevices.enumerateDevices()
.then(function (devices) {
devices.forEach(function (device) {
var option = document.createElement('option');
option.value = device.deviceId;
if (device.kind === 'videoinput') {
option.text = device.label || 'camera' + (videoSelect.length + 1);
videoSelect.appendChild(option);
} else if (device.kind == 'audioinput') {
option.text = device.label || 'mic' + (audioSelect.length + 1);
audioSelect.appendChild(option);
}
});
})
.catch(function (err) {
console.log(err.name + ": " + err.message);
});

关于html - Firefox 不支持 mediastreamtrack.getsources,如何做等效的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20110611/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com