Skip to content

🎥 Make videos programmatically with React

add "object-fit: contain" to <OffthreadVideo> by default

Jonny Burgerc2440fc9c5ff
diff --git a/packages/core/src/video/OffthreadVideoForRendering.tsx b/packages/core/src/video/OffthreadVideoForRendering.tsx
index 2fc57a9045..9d67cc1af5 100644
--- a/packages/core/src/video/OffthreadVideoForRendering.tsx
+++ b/packages/core/src/video/OffthreadVideoForRendering.tsx
@@ -20,6 +20,7 @@ export const OffthreadVideoForRendering: React.FC<OffthreadVideoProps> = ({
playbackRate,
src,
muted,
+ style,
...props
}) => {
const absoluteFrame = useAbsoluteCurrentFrame();
@@ -120,5 +121,12 @@ export const OffthreadVideoForRendering: React.FC<OffthreadVideoProps> = ({
[onError]
);
- return <Img src={actualSrc} {...props} onError={onErr} />;
+ const actualStyle: React.CSSProperties = useMemo(() => {
+ return {
+ objectFit: 'contain',
+ ...(style ?? {}),
+ };
+ }, [style]);
+
+ return <Img src={actualSrc} style={actualStyle} {...props} onError={onErr} />;
};