🎥 Make videos programmatically with React
use aspect ratio for videos
Jonny Burger9c1b6c4d1613
diff --git a/packages/player/src/utils/calculate-player-size.ts b/packages/player/src/utils/calculate-player-size.tsindex ed2ba9569d..116eca59a1 100644--- a/packages/player/src/utils/calculate-player-size.ts+++ b/packages/player/src/utils/calculate-player-size.ts@@ -14,26 +14,24 @@ export const calculatePlayerSize = ({compositionWidth: number;compositionHeight: number;}): React.CSSProperties => {- const aspectRatio = compositionWidth / compositionHeight;-- if (!currentSize) {+ if (width !== undefined && height === undefined) {return {- width: compositionWidth,- height: compositionHeight,+ aspectRatio: [compositionWidth, compositionHeight].join('/'),};}- // If has width specified, but no height, specify a default height that satisfies the aspect ratio.- if (width !== undefined && height === undefined) {+ // Opposite: If has height specified, evaluate the height and specify a default width.+ if (height !== undefined && width === undefined) {return {- height: currentSize.width / aspectRatio,+ // Aspect ratio CSS prop will work+ aspectRatio: [compositionWidth, compositionHeight].join('/'),};}- // Opposite: If has height specified, evaluate the height and specify a default width.- if (height !== undefined && width === undefined) {+ if (!currentSize) {return {- width: currentSize.height * aspectRatio,+ width: compositionWidth,+ height: compositionHeight,};}