Skip to content

🎥 Make videos programmatically with React

docs: migrate all docs that is left

Frenco5201505ccf0c
diff --git a/packages/docs/docs/absolute-fill.md b/packages/docs/docs/absolute-fill.md
index c17a1dc197..e8c6413f04 100644
--- a/packages/docs/docs/absolute-fill.md
+++ b/packages/docs/docs/absolute-fill.md
@@ -6,12 +6,14 @@ title: <AbsoluteFill />
A helper component - it is an absolutely positioned `<div>` with the following styles:
```css
-top: 0;
-left: 0;
-right: 0;
-bottom: 0;
-width: 100%;
-height: 100%;
-display: flex;
-flex-direction: column;
+.absolute-fill {
+ top: 0;
+ left: 0;
+ right: 0;
+ bottom: 0;
+ width: 100%;
+ height: 100%;
+ display: flex;
+ flex-direction: column;
+}
```
diff --git a/packages/docs/docs/audio.md b/packages/docs/docs/audio.md
index cbd848cf7e..44b092b632 100644
--- a/packages/docs/docs/audio.md
+++ b/packages/docs/docs/audio.md
@@ -17,7 +17,7 @@ The component also accepts a `volume` props which allows you to control the volu
`<Audio>` has two more helper props: `startFrom` and `endAt` for defining the start frame and end frame. Both are optional and do not get forwarded to the native `<audio>` element but tell Remotion which portion of the audio should be included.
-```tsx
+```tsx twoslash
import {Audio} from 'remotion';
import audio from './audio.mp3'
diff --git a/packages/docs/docs/easing.md b/packages/docs/docs/easing.md
index c2f16009c1..a626945668 100644
--- a/packages/docs/docs/easing.md
+++ b/packages/docs/docs/easing.md
@@ -47,7 +47,9 @@ The following helpers are used to modify other easing functions.
## Example
-```tsx
+```tsx twoslash
+import {useCurrentFrame, AbsoluteFill} from 'remotion'
+// ---cut---
import {interpolate, Easing} from 'remotion';
const MyVideo: React.FC = () => {
diff --git a/packages/docs/docs/iframe.md b/packages/docs/docs/iframe.md
index c5ccaedbb2..7cdfca52a9 100644
--- a/packages/docs/docs/iframe.md
+++ b/packages/docs/docs/iframe.md
@@ -8,7 +8,7 @@ The difference is that if you use the component from Remotion, that Remotion wil
## Example
-```tsx
+```tsx twoslash
import {IFrame} from 'remotion';
export const MyComp: React.FC = () => {
diff --git a/packages/docs/docs/img.md b/packages/docs/docs/img.md
index fbf309041a..f07dce4211 100644
--- a/packages/docs/docs/img.md
+++ b/packages/docs/docs/img.md
@@ -8,7 +8,7 @@ The difference is that if you use the component from Remotion, that Remotion wil
## Example
-```tsx
+```tsx twoslash
import {Img} from 'remotion';
import hi from './hi.png'
diff --git a/packages/docs/docs/player.md b/packages/docs/docs/player.md
index c6de4c6704..b886bf6855 100644
--- a/packages/docs/docs/player.md
+++ b/packages/docs/docs/player.md
@@ -224,12 +224,15 @@ Stop listening to an event. See the [Events](#events) section to see the functio
Using a [player ref](#playerref), you can bind event listeners to get notified of certain events of the player.
-```tsx
+```tsx twoslash
+import {useRef, useEffect} from 'react';
+import {PlayerRef} from '@remotion/player';
+// ---cut---
const playerRef = useRef<PlayerRef>(null);
useEffect(() => {
if (!playerRef.current) {
- return null;
+ return;
}
playerRef.current.addEventListener('play', () => {
console.log('playing');
@@ -253,8 +256,12 @@ useEffect(() => {
Fired when the time position changes. You may get the current frame by reading it from `e.detail.frame`.
-```tsx
-playerRef.current.addEventListener('seeked', (e) => {
+```tsx twoslash
+import {useRef, useEffect} from 'react';
+import {PlayerRef} from '@remotion/player';
+const playerRef = useRef<PlayerRef>(null);
+// ---cut---
+playerRef.current?.addEventListener('seeked', (e) => {
console.log('seeked to ' + e.detail.frame); // seeked to 120
});
```
@@ -279,8 +286,12 @@ Fires when an error or uncaught exception has happened in the video.
You may get the error by reading the `e.detail.error` value:
-```tsx
-ref.current.addEventListener('error', (e) => {
+```tsx twoslash
+import {useRef, useEffect} from 'react';
+import {PlayerRef} from '@remotion/player';
+const ref = useRef<PlayerRef>(null);
+// ---cut---
+ref.current?.addEventListener('error', (e) => {
console.log('error ', e.detail.error); // error [Error: undefined is not a function]
});
```
diff --git a/packages/docs/docs/sequence.mdx b/packages/docs/docs/sequence.mdx
index c063ea65ed..dfcff6c08e 100644
--- a/packages/docs/docs/sequence.mdx
+++ b/packages/docs/docs/sequence.mdx
@@ -6,6 +6,11 @@ sidebar_label: <Sequence />
import { SequenceForwardExample } from "../components/SequenceExamples/SequenceForward";
+```twoslash include example
+const BlueSquare: React.FC = () => <div></div>
+// - BlueSquare
+```
+
Using a Sequence, you can time-shift certain parts of your animation and therefore make them more reusable. Sequences are also shown in the timeline and help you visually understand the structure of your video.
## API
@@ -32,7 +37,9 @@ All the examples below are based on the following animation of a blue square:
<br />
-```tsx
+```tsx twoslash
+// @include: example-BlueSquare
+// ---cut---
const MyVideo = () => {
return (
<BlueSquare />
@@ -47,7 +54,10 @@ If you would like to delay the content by say 30 frames, you can wrap it in <br/
<SequenceForwardExample type="delay" />
<br />
-```tsx
+```tsx twoslash
+// @include: example-BlueSquare
+import {Sequence} from "remotion";
+// ---cut---
const MyVideo = () => {
return (
<Sequence from={30} durationInFrames={Infinity}>
@@ -80,7 +90,10 @@ You need to wrap the videos in two sequences. To the inner one we pass a negativ
<SequenceForwardExample type="trim-and-delay" />
<br />
-```tsx
+```tsx twoslash
+// @include: example-BlueSquare
+import {Sequence} from "remotion";
+// ---cut---
const TrimAndDelayExample: React.FC = () => {
return (
<Sequence from={30} durationInFrames={Infinity}>
diff --git a/packages/docs/docs/video.md b/packages/docs/docs/video.md
index ac2434737f..660d1e1bd5 100644
--- a/packages/docs/docs/video.md
+++ b/packages/docs/docs/video.md
@@ -13,7 +13,7 @@ Use an import or require to load an video file and pass it as the `src` prop. Al
`<Video>` has two more helper props: `startFrom` and `endAt` to define when the video should start and end. Both are optional and do not get forwarded to the native `<video>` element but tell Remotion which portion of the video to use.
-```tsx
+```tsx twoslash
import {Video} from 'remotion';
import video from './video.webm';