加载设备信息页面
加载完设备信息页面
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);
}