Skip to content

🎥 Make videos programmatically with React

`@remotion/player`: Hide player while styles are loading

Jonny Burger0c6ae57b37bc
diff --git a/packages/player/src/PlayerUI.tsx b/packages/player/src/PlayerUI.tsx
index bf62947aa1..363f28c658 100644
--- a/packages/player/src/PlayerUI.tsx
+++ b/packages/player/src/PlayerUI.tsx
@@ -462,8 +462,14 @@ const PlayerUI: React.ForwardRefRenderFunction<
const VideoComponent = video ? video.component : null;
const outerStyle: React.CSSProperties = useMemo(() => {
- return calculateOuterStyle({canvasSize, config, style, overflowVisible});
- }, [canvasSize, config, overflowVisible, style]);
+ return calculateOuterStyle({
+ canvasSize,
+ config,
+ style,
+ overflowVisible,
+ layout,
+ });
+ }, [canvasSize, config, layout, overflowVisible, style]);
const outer = useMemo(() => {
return calculateOuter({config, layout, scale, overflowVisible});
diff --git a/packages/player/src/calculate-scale.ts b/packages/player/src/calculate-scale.ts
index 1c810e233e..091ffc7f19 100644
--- a/packages/player/src/calculate-scale.ts
+++ b/packages/player/src/calculate-scale.ts
@@ -51,11 +51,13 @@ export const calculateOuterStyle = ({
style,
canvasSize,
overflowVisible,
+ layout,
}: {
config: VideoConfig | null;
style: React.CSSProperties | undefined;
canvasSize: Size | null;
overflowVisible: boolean;
+ layout: Layout | null;
}): React.CSSProperties => {
if (!config) {
return {};
@@ -71,6 +73,7 @@ export const calculateOuterStyle = ({
height: style?.height as StandardLonghandProperties['width'],
width: style?.width as StandardLonghandProperties['height'],
}),
+ opacity: layout ? 1 : 0,
...style,
};
};