mirror of
https://github.com/bluenviron/mediamtx
synced 2025-01-19 13:31:00 +00:00
webrtc: in publish page, prevent same device from appearing multiple times (#3261)
This commit is contained in:
parent
851358a379
commit
9e718f9dd9
@ -577,28 +577,28 @@ const onPublish = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const selectHasOption = (select, option) => {
|
||||||
|
for (const opt of select.querySelectorAll('option')) {
|
||||||
|
if (opt.value === option) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
const populateDevices = () => {
|
const populateDevices = () => {
|
||||||
return navigator.mediaDevices.enumerateDevices()
|
return navigator.mediaDevices.enumerateDevices()
|
||||||
.then((devices) => {
|
.then((devices) => {
|
||||||
for (const device of devices) {
|
for (const device of devices) {
|
||||||
switch (device.kind) {
|
if (device.kind === 'videoinput' || device.kind === 'audioinput') {
|
||||||
case 'videoinput':
|
const select = (device.kind === 'videoinput') ? videoForm.device : audioForm.device;
|
||||||
{
|
|
||||||
const opt = document.createElement('option');
|
|
||||||
opt.value = device.deviceId;
|
|
||||||
opt.text = device.label;
|
|
||||||
videoForm.device.appendChild(opt);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'audioinput':
|
if (!selectHasOption(select, device.deviceId)) {
|
||||||
{
|
|
||||||
const opt = document.createElement('option');
|
const opt = document.createElement('option');
|
||||||
opt.value = device.deviceId;
|
opt.value = device.deviceId;
|
||||||
opt.text = device.label;
|
opt.text = device.label;
|
||||||
audioForm.device.appendChild(opt);
|
select.appendChild(opt);
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user