Device IDs are bound to a combination of domain and browser. If
you want to use electron-capture, open this URL on the electron-capture
- app.
+ app.
+ Click device names to preset them. Select multiple audio inputs by clicking multiple devices.
Check for browser and camera capabilities here.
@@ -41,7 +42,7 @@
- Click to copy. Send this to your host:
+ Click to copy. Use this URL to preset audio/video devices.×
@@ -63,15 +64,19 @@
return value.kind === "videoinput";
}
+ function sanitizeDeviceName(deviceName) {
+ return String(deviceName).toLowerCase().replace(/[\W]+/g, "_");
+ }
+
function addDevice(element) {
- const info = element.getElementsByClassName("device-id")[0];
- const type = info.dataset.deviceType;
+ const type = element.dataset.deviceType;
+ const device = sanitizeDeviceName(element.querySelector('span').innerText);
if (type === "audioinput") {
- setAudioSearchParams(info);
+ setAudioSearchParams(element);
}
if (type === "videoinput") {
- setVideoSearchParams(info);
+ setVideoSearchParams(element);
}
if (type === "audiooutput") {
return;
@@ -84,9 +89,9 @@
function setAudioSearchParams(info) {
// Device was already selected
- if (info.parentNode.className === "device selected") {
+ if (info.className === "device selected") {
// Remove device from list of selected devices
- const index = audioInputDevices.indexOf(info.innerText);
+ const index = audioInputDevices.indexOf(device);
if (index !== -1) {
audioInputDevices.splice(index, 1);
}
@@ -101,7 +106,8 @@
}
} else {
// Device is unselected
- audioInputDevices.push(info.innerText);
+
+ audioInputDevices.push(device);
url.searchParams.set("ad", audioInputDevices.join(","));
element.className = "device selected";
}
@@ -112,11 +118,12 @@
*/
function setVideoSearchParams(info) {
// Device was already selected
- if (info.parentNode.className === "device selected") {
- info.parentNode.className = "device";
+ if (info.className === "device selected") {
+ element.className = "device";
+
// Set the url param to the devices that are left
- url.searchParams.set("vd", info.innerText);
+ url.searchParams.set("vd", device);
element.className = "device";
// If no devices remained, just remove the param completely
@@ -125,7 +132,13 @@
}
} else {
// Device is unselected
- url.searchParams.set("vd", info.innerText);
+ try {
+ element.parentElement.querySelector('.device.selected').className = "device";
+ } catch (error) {
+ console.log("There was no video device already selected.");
+ }
+
+ url.searchParams.set("vd", device);
element.className = "device selected";
}
}
@@ -147,9 +160,9 @@
.sort()
.forEach(([key, value]) => {
output += `
-