diff --git a/packages/webui/components/viewers/video-player.tsx b/packages/webui/components/viewers/video-player.tsx index 285575db..5cdd6979 100644 --- a/packages/webui/components/viewers/video-player.tsx +++ b/packages/webui/components/viewers/video-player.tsx @@ -376,8 +376,14 @@ const VideoPlayer: React.FC = ({ const [videoHtmlEl, setVideoHtmlEl] = useState(undefined) const videoRef = useRef(null) const [zoom, setZoom] = useState(1) + const [hasManuallyZoomed, setHasManuallyZoomed] = useState(false) const [containerSize, setContainerSize] = useState({ width: 0, height: 0 }) + const handleZoomChange = (newZoom: number) => { + setZoom(newZoom) + setHasManuallyZoomed(true) + } + // Store const { isDrawing, @@ -406,20 +412,17 @@ const VideoPlayer: React.FC = ({ return () => observer.disconnect() }, []) - // Fit to screen initial + // Fit to screen initial / responsive resize useEffect(() => { if (containerSize.width > 0 && containerSize.height > 0) { - // Only if not already set or reset? - // Actually, we want to start fit. const vidW = data.media?.metadata?.originalWidth ?? 1920 const vidH = data.media?.metadata?.originalHeight ?? 1080 const scale = Math.min(containerSize.width / vidW, containerSize.height / vidH) - // Only set if zoom is 1 (initial). - if (zoom === 1) { + if (!hasManuallyZoomed) { setZoom(scale) } } - }, [containerSize.width, containerSize.height, data.media?.metadata]) + }, [containerSize.width, containerSize.height, data.media?.metadata, hasManuallyZoomed]) // Cleanup ref when player is disposed useEffect(() => { @@ -922,7 +925,7 @@ const VideoPlayer: React.FC = ({ changeResolution={changeResolution} handleDownload={handleDownload} toggleFullScreen={toggleFullScreen} - onZoomChange={setZoom} + onZoomChange={handleZoomChange} frameRate={frameRate} totalFrames={totalFrames} currentFrame={currentFrame}