Skip to content

Commit 76713a8

Browse files
committed
Move dimensions update to handleLoadedData for safari. Only update if non-zero
1 parent 2edd0d3 commit 76713a8

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

dotcom-rendering/src/components/SelfHostedVideo.importable.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -529,14 +529,17 @@ export const SelfHostedVideo = ({
529529
cue.line = percentFromTop;
530530
}
531531
}
532-
533-
setWidth(video.videoWidth);
534-
setHeight(video.videoHeight);
535532
};
536533

537534
const handleLoadedData = () => {
538-
if (vidRef.current) {
539-
setHasAudio(doesVideoHaveAudio(vidRef.current));
535+
const video = vidRef.current;
536+
if (!video) return;
537+
538+
setHasAudio(doesVideoHaveAudio(video));
539+
540+
if (video.videoWidth > 0 && video.videoHeight > 0) {
541+
setWidth(video.videoWidth);
542+
setHeight(video.videoHeight);
540543
}
541544
};
542545

0 commit comments

Comments
 (0)