Update voice demo camera drawer

This commit is contained in:
Xin Wang
2026-06-02 13:22:08 +08:00
parent aae751f3f3
commit 89d0777830
3 changed files with 42 additions and 67 deletions

View File

@@ -78,6 +78,7 @@ const els = {
cameraPhoto: document.getElementById("camera-photo"),
cameraCanvas: document.getElementById("camera-canvas"),
cameraStartBtn: document.getElementById("camera-start-btn"),
cameraDeviceRow: document.getElementById("camera-device-row"),
cameraDeviceSelect: document.getElementById("camera-device-select"),
cameraUpload: document.getElementById("camera-upload"),
cameraSamples: document.getElementById("camera-samples"),
@@ -257,9 +258,6 @@ function syncCameraDrawer(value) {
els.cameraQuestion.textContent = prompt;
renderSampleThumbnails();
selectDefaultImage();
refreshVideoDevices().then(() => {
if (!state.cameraActive) populateDeviceSelect();
});
} else {
els.cameraState.textContent = "状态 -";
els.cameraQuestion.textContent = "";
@@ -987,6 +985,8 @@ async function startCamera(deviceId) {
state.cameraStream.getVideoTracks?.()[0]?.getSettings?.().deviceId ||
deviceId;
populateDeviceSelect(activeId);
// Reveal the camera device dropdown only while the camera is in use.
els.cameraDeviceRow.hidden = false;
setCameraButtonEnabled();
}
@@ -998,6 +998,7 @@ function stopCameraStream() {
els.cameraVideo.srcObject = null;
state.cameraActive = false;
els.cameraStartBtn.classList.remove("is-active");
els.cameraDeviceRow.hidden = true;
}
function captureFromCamera() {