diff --git a/examples/webpage/app.js b/examples/webpage/app.js index 269ebb0..64e1499 100644 --- a/examples/webpage/app.js +++ b/examples/webpage/app.js @@ -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() { diff --git a/examples/webpage/index.html b/examples/webpage/index.html index 4d6d4c7..1bd37b7 100644 --- a/examples/webpage/index.html +++ b/examples/webpage/index.html @@ -108,51 +108,15 @@

+
+
-
- - -
+
-
+