diff --git a/src/screen-name/view/VideoPlayerNode.ts b/src/screen-name/view/VideoPlayerNode.ts index b4ffa34..8987af1 100644 --- a/src/screen-name/view/VideoPlayerNode.ts +++ b/src/screen-name/view/VideoPlayerNode.ts @@ -406,6 +406,10 @@ export class VideoPlayerNode extends Node { /** Reset the video source selection to the initial state. */ public reset(): void { + if (this.currentBlobUrl) { + URL.revokeObjectURL(this.currentBlobUrl); + this.currentBlobUrl = null; + } this.videoSourceControlNode.reset(); this.videoElement.removeAttribute("src"); this.videoElement.load(); diff --git a/src/screen-name/view/VideoSourceControlNode.ts b/src/screen-name/view/VideoSourceControlNode.ts index f705a93..960904d 100644 --- a/src/screen-name/view/VideoSourceControlNode.ts +++ b/src/screen-name/view/VideoSourceControlNode.ts @@ -451,7 +451,7 @@ export class VideoSourceControlNode extends HBox { const fps = frameCount > 0 && duration > 0 ? frameCount / duration : DEFAULT_FRAME_RATE; storeAndLoad(duration, fps, frameCount > 0 ? frameCount : undefined); }) - .catch(() => storeAndLoad(0)); + .catch(() => storeAndLoad(0)); // Frame counting failed; load with unknown duration (0) } else { // Read duration via a temporary video element, then store and load const tempUrl = URL.createObjectURL(blob); @@ -506,11 +506,7 @@ export class VideoSourceControlNode extends HBox { listener: async () => { isPlayingProperty.value = false; this.webcamPanel.visible = true; - try { - await this.webcamPanel.open(); - } catch { - this.webcamPanel.visible = false; - } + await this.webcamPanel.open(); }, }); diff --git a/src/screen-name/view/WebcamPanel.ts b/src/screen-name/view/WebcamPanel.ts index 8b80916..87a5357 100644 --- a/src/screen-name/view/WebcamPanel.ts +++ b/src/screen-name/view/WebcamPanel.ts @@ -288,16 +288,20 @@ export class WebcamPanel extends Node { this.setStatus(this.webcamStrings.requestingAccessStringProperty.value); this._startButton.enabled = false; - const granted = await this.recorder.requestPermission(); - if (!granted) { + try { + const granted = await this.recorder.requestPermission(); + if (!granted) { + this.setStatus(this.webcamStrings.accessDeniedStringProperty.value); + return; + } + + await this.populateCameras(); + await this.recorder.startPreview(this.previewElement, this.cameraSelect.value || undefined); + this.clearStatus(); + this._startButton.enabled = true; + } catch { this.setStatus(this.webcamStrings.accessDeniedStringProperty.value); - return; } - - await this.populateCameras(); - await this.recorder.startPreview(this.previewElement, this.cameraSelect.value || undefined); - this.clearStatus(); - this._startButton.enabled = true; } // Reset visibility to preview phase without touching the camera stream. @@ -425,7 +429,7 @@ export class WebcamPanel extends Node { blob = fixed.blob; duration = fixed.duration; } catch { - // Fall back to the raw blob with unknown duration + this.clearStatus(); // Metadata fix failed; continue with raw blob and unknown duration } }