Skip to content

🎥 Make videos programmatically with React

series documentation

Jonny Burger394c9255c54c
diff --git a/packages/docs/components/SeriesExamples/SeriesExample.tsx b/packages/docs/components/SeriesExamples/SeriesExample.tsx
new file mode 100644
index 0000000000..a6dbd4ba79
--- /dev/null
+++ b/packages/docs/components/SeriesExamples/SeriesExample.tsx
@@ -0,0 +1,72 @@
+import { Player } from "@remotion/player";
+import React from "react";
+import { AbsoluteFill, Series, useCurrentFrame } from "remotion";
+
+const Square: React.FC<{
+ color: string;
+}> = ({ color }) => {
+ const frame = useCurrentFrame();
+ return (
+ <AbsoluteFill style={{ justifyContent: "center", alignItems: "center" }}>
+ <div
+ style={{
+ height: 200,
+ width: 200,
+ backgroundColor: color,
+ borderRadius: 20,
+ justifyContent: "center",
+ alignItems: "center",
+ display: "flex",
+ color: "rgba(255, 255, 255, 0.7)",
+ fontSize: 50,
+ }}
+ >
+ {frame}
+ </div>
+ </AbsoluteFill>
+ );
+};
+
+const BaseExample: React.FC = () => {
+ return (
+ <Series>
+ <Series.Sequence durationInFrames={40}>
+ <Square color={"#3498db"} />
+ </Series.Sequence>
+ <Series.Sequence durationInFrames={20}>
+ <Square color={"#5ff332"} />
+ </Series.Sequence>
+ <Series.Sequence durationInFrames={70}>
+ <Square color={"#fdc321"} />
+ </Series.Sequence>
+ </Series>
+ );
+};
+
+export const SeriesExample: React.FC<{
+ type: "base";
+}> = ({ type }) => {
+ const component = (() => {
+ if (type === "base") {
+ return BaseExample;
+ }
+
+ throw new TypeError("oops");
+ })();
+ return (
+ <div>
+ <Player
+ component={component}
+ compositionWidth={1280}
+ compositionHeight={720}
+ controls
+ durationInFrames={150}
+ fps={30}
+ style={{
+ width: "100%",
+ }}
+ loop
+ />
+ </div>
+ );
+};
diff --git a/packages/docs/docs/sequence.mdx b/packages/docs/docs/sequence.mdx
index 751e95841f..f66ef92007 100644
--- a/packages/docs/docs/sequence.mdx
+++ b/packages/docs/docs/sequence.mdx
@@ -23,7 +23,7 @@ The Sequence component is a high order component and accepts, besides it's child
- `name` _(optional)_: You can give your sequence a name and it will be shown as the label of the sequence in the timeline of the Remotion preview. This property is purely for helping you keep track of sequences in the timeline.
-- `layout`: _(optional)_: Either `"absolute-fill"` _(default)_ or `"none"` By default, your sequence will be absolutely positioned, so they will overlay each other. If you would like to opt out of it and handle layouting yourself, pass `layout="none"`. Available since v1.4.
+- `layout`: _(optional)_: Either `"absolute-fill"` _(default)_ or `"none"` By default, your sequences will be absolutely positioned, so they will overlay each other. If you would like to opt out of it and handle layouting yourself, pass `layout="none"`. Available since v1.4.
:::info
Good to know: You can nest sequences within each other and they will cascade. For example, a sequence that starts at frame 60 which is inside a sequence that starts at frame 30 will have it's children start at frame 90. However, nested sequences are not currently displayed in the timeline.
diff --git a/packages/docs/docs/series.md b/packages/docs/docs/series.md
new file mode 100644
index 0000000000..76636dda2d
--- /dev/null
+++ b/packages/docs/docs/series.md
@@ -0,0 +1,69 @@
+---
+id: series
+title: <Series />
+sidebar_label: <Series />
+---
+
+_Available from v.2.3.1_
+
+import { SeriesExample } from "../components/SeriesExamples/SeriesExample";
+
+Using this component, you can easily stitch together scenes that should play sequentially after another.
+
+## Example
+
+### Code
+
+```twoslash include example
+const Square: React.FC<{color: string}> = () => <div></div>
+// - Square
+```
+
+```tsx twoslash
+// @include: example-Square
+// ---cut---
+import {Series} from 'remotion';
+
+const Example: React.FC = () => {
+ return (
+ <Series>
+ <Series.Sequence durationInFrames={40}>
+ <Square color={"#3498db"} />
+ </Series.Sequence>
+ <Series.Sequence durationInFrames={20}>
+ <Square color={"#5ff332"} />
+ </Series.Sequence>
+ <Series.Sequence durationInFrames={70}>
+ <Square color={"#fdc321"} />
+ </Series.Sequence>
+ </Series>
+ );
+};
+```
+
+### Result
+
+<SeriesExample type="base" />
+
+## API
+
+The `<Series />` component takes no props may only contain a list of `<Series.Sequence />` instances.
+
+### `<Series.Sequence />`
+
+This component is a high order component, and accepts, besides it's children, the following props:
+
+- `durationInFrames` _(required)_: For how many frames the sequence should be displayed. Children are unmounted if they are not within the time range of display. If you don't want to limit the duration of the sequence, you can pass `Infinity`.
+
+- `offset`: _(optional)_: Pass a positive number to delay the beginning of the sequence. Pass a negative number to start the sequence earlier, and to overlay the sequence with the one that comes before.
+
+ The offset does not apply to sequences that come before, but the sequences that come after it will also be shifted.
+
+ **Example 1**: Pass `10` to delay the sequence by 10 frames and create a blank space of 10 frames before it.
+ **Example 2**: Pass `-10` to start the sequence earlier and overlay the sequence on top of the previous one for 10 frames.
+
+- `layout`: _(optional)_: Either `"absolute-fill"` _(default)_ or `"none"` By default, your sequences will be absolutely positioned, so they will overlay each other. If you would like to opt out of it and handle layouting yourself, pass `layout="none"`.
+
+## See also
+
+- [`<Sequence />`](/docs/sequence)
diff --git a/packages/docs/sidebars.js b/packages/docs/sidebars.js
index 4308aaae17..6e10591433 100644
--- a/packages/docs/sidebars.js
+++ b/packages/docs/sidebars.js
@@ -65,6 +65,7 @@ module.exports = {
"iframe",
"freeze",
"still",
+ "series",
"easing",
],
},