【WebRtc】获取媒体设备信息
加载设备信息页面

加载完设备信息页面

Code
/**
* 加载当前设备的音视频信息
*/
initInnerLocalDevice() {
let that = this;
// 判断是否支持
if (!navigator.mediaDevices || !navigator.mediaDevices.enumerateDevices) {
that.$notify({
title: '警告',
message: '浏览器不支持获取媒体设备',
type: 'warning'
});
return;
}
this.loading = true
navigator.mediaDevices.enumerateDevices()
.then(devices => {
devices.forEach(function (device) {
let obj = {id: device.deviceId, kind: device.kind, label: device.label}
if (device.kind === 'audioinput') {
if (that.audioInArray.filter(e => e.id === device.deviceId).length === 0) {
that.audioInArray.push(obj)
}
} else if (device.kind === 'audiooutput') {
if (that.audioOutArray.filter(e => e.id === device.deviceId).length === 0) {
that.audioOutArray.push(obj)
}
} else if (device.kind === 'videoinput') {
if (that.videoOutArray.filter(e => e.id === device.deviceId).length === 0) {
that.videoOutArray.push(obj)
}
}
});
this.loading = false
}).catch(this.handleError);
}
期待更新,麻烦点个赞,点个关注,栓Q !
本文作者:Hello、Lin
本文链接:https://www.cnblogs.com/HelloWxl/p/17203772.html
版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步