Skip to content

🎥 Make videos programmatically with React

player scaling docs

Jonny Burger7f5b9c58a5b6
diff --git a/packages/docs/docs/player/api.md b/packages/docs/docs/player/api.md
index cce200aefe..06ce31a744 100644
--- a/packages/docs/docs/player/api.md
+++ b/packages/docs/docs/player/api.md
@@ -5,7 +5,7 @@ title: "API"
## `<Player />`
-A React component which takes the following props
+A React component which takes the following props:
### `component` or `lazyComponent`
diff --git a/packages/docs/docs/player/player-examples.md b/packages/docs/docs/player/player-examples.md
index 58e49604e4..7f4ba80f33 100644
--- a/packages/docs/docs/player/player-examples.md
+++ b/packages/docs/docs/player/player-examples.md
@@ -2,7 +2,6 @@
id: examples
sidebar_label: "Examples"
title: "Examples for @remotion/player"
-slug: /player/examples
---
## Bare example
@@ -114,8 +113,8 @@ export const App: React.FC = () => {
};
```
-:::tip
-You can also use percentages and other units. We'll publish a guide for sizing the `<Player />` before the official release.
+:::note
+See [Scaling](/docs/player/scaling) for more ways to scale the Player.
:::
## Adding autoplay
diff --git a/packages/docs/docs/player/player-integration.md b/packages/docs/docs/player/player-integration.md
index 72b4891f84..f6ed0b5e89 100644
--- a/packages/docs/docs/player/player-integration.md
+++ b/packages/docs/docs/player/player-integration.md
@@ -1,8 +1,6 @@
---
id: integration
-sidebar_label: "Code sharing"
title: "Code sharing"
-slug: /player/integration
---
import Tabs from "@theme/Tabs";
diff --git a/packages/docs/docs/player/scaling.md b/packages/docs/docs/player/scaling.md
new file mode 100644
index 0000000000..4f96fad973
--- /dev/null
+++ b/packages/docs/docs/player/scaling.md
@@ -0,0 +1,31 @@
+---
+id: scaling
+title: "Scaling"
+---
+
+The following algorithm is used for calculating the size of the Player:
+
+1. By default, the Player is as big as the composition height, defined by the `compositionHeight` and `compositionWidth` props.
+1. If `height` and `width` is defined using the `style` property, the player will assume the dimensions you have passed.
+1. If a `height` is passed using the `style` property, the player will assume that height, and calculate the width based on the aspect ratio of the video.
+1. If `width` is passed using the `style` property, the player will assume that width and calculate the width based on the aspect ration of the video.
+
+## Full width
+
+By setting the following style:
+
+```tsx
+style={{ width: "100%" }}
+```
+
+The video will scale to the full width of the parent container, while the height will be calculated based on the aspect ratio of the video.
+
+## Fitting to a container
+
+You can use
+
+```tsx
+style={{ width: "100%", height: "100%" }}
+```
+
+to make the `<Player />` fit the whole container. Note that if the player size does not match the video aspect ratio, the video gets scaled down and centered in the player.
diff --git a/packages/docs/sidebars.js b/packages/docs/sidebars.js
index fb4910f487..6bd23f9d12 100644
--- a/packages/docs/sidebars.js
+++ b/packages/docs/sidebars.js
@@ -8,6 +8,7 @@ module.exports = {
"player/player",
"player/api",
"player/examples",
+ "player/scaling",
"player/integration",
"player/autoplay",
],