mirror of
https://github.com/bluenviron/mediamtx
synced 2025-01-19 05:21:09 +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 = () => {
|
||||
return navigator.mediaDevices.enumerateDevices()
|
||||
.then((devices) => {
|
||||
for (const device of devices) {
|
||||
switch (device.kind) {
|
||||
case 'videoinput':
|
||||
{
|
||||
const opt = document.createElement('option');
|
||||
opt.value = device.deviceId;
|
||||
opt.text = device.label;
|
||||
videoForm.device.appendChild(opt);
|
||||
}
|
||||
break;
|
||||
if (device.kind === 'videoinput' || device.kind === 'audioinput') {
|
||||
const select = (device.kind === 'videoinput') ? videoForm.device : audioForm.device;
|
||||
|
||||
case 'audioinput':
|
||||
{
|
||||
if (!selectHasOption(select, device.deviceId)) {
|
||||
const opt = document.createElement('option');
|
||||
opt.value = device.deviceId;
|
||||
opt.text = device.label;
|
||||
audioForm.device.appendChild(opt);
|
||||
select.appendChild(opt);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user