Skip to content

🎥 Make videos programmatically with React

alright

Jonny Burgerf6f6a0c59887
diff --git a/packages/docs/docs/studio/TableOfContents.tsx b/packages/docs/docs/studio/TableOfContents.tsx
index 6a918d9436..40794d057e 100644
--- a/packages/docs/docs/studio/TableOfContents.tsx
+++ b/packages/docs/docs/studio/TableOfContents.tsx
@@ -40,6 +40,18 @@ export const TableOfContents: React.FC = () => {
<strong>{'restartStudio()'}</strong>
<div>Restart the Studio Server.</div>
</TOCItem>
+ <TOCItem link="/docs/studio/play">
+ <strong>{'play()'}</strong>
+ <div>Start playback in the timeline</div>
+ </TOCItem>
+ <TOCItem link="/docs/studio/pause">
+ <strong>{'pause()'}</strong>
+ <div>Pause playback in the timeline</div>
+ </TOCItem>
+ <TOCItem link="/docs/studio/toggle">
+ <strong>{'toggle()'}</strong>
+ <div>Toggle playback in the timeline</div>
+ </TOCItem>
<TOCItem link="/docs/studio/seek">
<strong>{'seek()'}</strong>
<div>Jump to a position in the timeline</div>
@@ -55,4 +67,4 @@ export const TableOfContents: React.FC = () => {
</Grid>
</div>
);
-};
+};
\ No newline at end of file
diff --git a/packages/docs/docs/studio/pause.mdx b/packages/docs/docs/studio/pause.mdx
new file mode 100644
index 0000000000..faa8fddee6
--- /dev/null
+++ b/packages/docs/docs/studio/pause.mdx
@@ -0,0 +1,33 @@
+---
+image: /generated/articles-docs-studio-pause.png
+title: pause()
+crumb: '@remotion/studio'
+---
+
+# pause()<AvailableFrom v="v4.0.287"/>
+
+Pauses playback in the Remotion Studio.
+
+## Examples
+
+```tsx twoslash title="Pause on button click"
+import {pause} from '@remotion/studio';
+
+const PauseButton = () => {
+ return <button onClick={pause}>Pause</button>;
+};
+```
+
+```tsx twoslash title="Pause programmatically"
+import {pause} from '@remotion/studio';
+
+// Pause playback
+pause();
+```
+
+## See also
+
+- [play()](/docs/studio/play)
+- [toggle()](/docs/studio/toggle)
+- [seek()](/docs/studio/seek)
+- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/studio/src/api/pause.ts)
diff --git a/packages/docs/docs/studio/play.mdx b/packages/docs/docs/studio/play.mdx
new file mode 100644
index 0000000000..4ab6591a3f
--- /dev/null
+++ b/packages/docs/docs/studio/play.mdx
@@ -0,0 +1,36 @@
+---
+image: /generated/articles-docs-studio-play.png
+title: play()
+crumb: '@remotion/studio'
+---
+
+# play()<AvailableFrom v="v4.0.287"/>
+
+Starts playback in the Remotion Studio.
+
+The function accepts an optional event parameter which can be a `React.SyntheticEvent` or a [`PointerEvent`](https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent). This allows the function to be used directly as an event handler.
+
+## Examples
+
+```tsx twoslash title="Start playing on button click"
+import {play} from '@remotion/studio';
+
+const PlayButton = () => {
+ // Call with the event parameter for better browser audio autoplay
+ return <button onClick={(e) => play(e)}>Play</button>;
+};
+```
+
+```tsx twoslash title="Start playing programmatically"
+import {play} from '@remotion/studio';
+
+// Call without event parameter
+play();
+```
+
+## See also
+
+- [pause()](/docs/studio/pause)
+- [toggle()](/docs/studio/toggle)
+- [seek()](/docs/studio/seek)
+- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/studio/src/api/play.ts)
diff --git a/packages/docs/docs/studio/toggle.mdx b/packages/docs/docs/studio/toggle.mdx
new file mode 100644
index 0000000000..2b247faf7b
--- /dev/null
+++ b/packages/docs/docs/studio/toggle.mdx
@@ -0,0 +1,37 @@
+---
+image: /generated/articles-docs-studio-toggle.png
+title: toggle()
+crumb: '@remotion/studio'
+---
+
+# toggle()<AvailableFrom v="4.0.287"/>
+
+Toggles playback in the Remotion Studio. If the composition is currently playing, it will pause. If it's paused, it will start playing.
+
+The function accepts an optional event parameter which can be a `React.SyntheticEvent` or a [`PointerEvent`](https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent). This allows the function to be used directly as an event handler.
+
+## Examples
+
+```tsx twoslash title="Toggle playback on button click"
+import {toggle} from '@remotion/studio';
+
+const ToggleButton = () => {
+ // Call with the event parameter for better browser audio autoplay
+
+ return <button onClick={(e) => toggle(e)}>Play/Pause</button>;
+};
+```
+
+```tsx twoslash title="Toggle playback programmatically"
+import {toggle} from '@remotion/studio';
+
+// Call without event parameter
+toggle();
+```
+
+## See also
+
+- [play()](/docs/studio/play)
+- [pause()](/docs/studio/pause)
+- [seek()](/docs/studio/seek)
+- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/studio/src/api/toggle.ts)
diff --git a/packages/docs/sidebars.js b/packages/docs/sidebars.js
index c206b6e42a..e53721cf99 100644
--- a/packages/docs/sidebars.js
+++ b/packages/docs/sidebars.js
@@ -543,6 +543,9 @@ module.exports = {
'studio/delete-static-file',
'studio/restart-studio',
'studio/save-default-props',
+ 'studio/play',
+ 'studio/pause',
+ 'studio/toggle',
'studio/seek',
'studio/update-default-props',
'studio/focus-default-props-path',
@@ -716,7 +719,6 @@ module.exports = {
label: '@remotion/fonts',
link: {
type: 'doc',
-
id: 'fonts-api/fonts-api',
},
items: ['fonts-api/load-font'],