Skip to content

Commit

Permalink
webrtc: in publish page, prevent same device from appearing multiple …
Browse files Browse the repository at this point in the history
…times
  • Loading branch information
aler9 committed Apr 17, 2024
1 parent 851358a commit 28c7c0d
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions internal/servers/webrtc/publish_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -577,28 +577,28 @@
}
};

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;
}
}

Expand Down

0 comments on commit 28c7c0d

Please sign in to comment.