Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

webrtc: fix loading default video and devices from query #3260

Merged
merged 1 commit into from
Apr 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions internal/servers/webrtc/publish_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -609,10 +609,12 @@
videoForm.device.appendChild(opt);
}

// set first available device as default device
if (videoForm.device.children.length !== 0) {
videoForm.device.value = videoForm.device.children[1].value;
}

// set first available device as default device
if (audioForm.device.children.length !== 0) {
audioForm.device.value = audioForm.device.children[1].value;
}
Expand Down Expand Up @@ -665,6 +667,10 @@
.forEach((track) => track.stop());

setMessage('');

loadValuesFromQuery();
setupEventListeners();

video.style.display = 'none';
controls.style.display = 'flex';
});
Expand All @@ -674,7 +680,7 @@
});
};

const updateQueryOnControls = () => {
const setupEventListeners = () => {
const url = new URL(window.location.href);
const inputs = [...Object.values(videoForm), ...Object.values(audioForm)]

Expand Down Expand Up @@ -702,7 +708,7 @@
}
};

const loadControlsFromQuery = () => {
const loadValuesFromQuery = () => {
const params = new URLSearchParams(window.location.search);
const inputs = [...Object.values(videoForm), ...Object.values(audioForm)]

Expand All @@ -714,7 +720,7 @@
} else if (input instanceof HTMLInputElement && input.type === 'checkbox') {
input.checked = value === 'true';
} else if (input instanceof HTMLSelectElement) {
input.value = value
input.value = value;
}
}
}
Expand All @@ -726,8 +732,6 @@
return;
}

loadControlsFromQuery();
updateQueryOnControls();
publishButton.addEventListener('click', onPublish);
populateOptions();
};
Expand Down
Loading