(null);
const near = useNearViewport(container);
const [failed, setFailed] = useState(false);
+ const [frame, setFrame] = useState<{ width: number; height: number } | null>(null);
const src = near ? artifactUrl(artifactId) : undefined;
if (failed) return ;
@@ -48,7 +49,8 @@ export function MediaPlayer({
);
}
- const box = videoBox(width, height);
+ // Uploads carry no dimensions; size the frame from the file once its metadata loads.
+ const box = videoBox(width ?? frame?.width, height ?? frame?.height);
return (
setFailed(true)}
+ onLoadedMetadata={(event) => {
+ const { videoWidth, videoHeight } = event.currentTarget;
+ if (videoWidth > 0 && videoHeight > 0) {
+ setFrame({ width: videoWidth, height: videoHeight });
+ }
+ }}
/>
);