Skip to content

🎥 Make videos programmatically with React

learn more about the buffer state

Jonny Burger144457056b22
diff --git a/packages/docs/docs/img.md b/packages/docs/docs/img.md
index 784d5860d7..132b6265f9 100644
--- a/packages/docs/docs/img.md
+++ b/packages/docs/docs/img.md
@@ -5,7 +5,7 @@ id: img
crumb: "API"
---
-The `<Img />` tag can be used like a regular `<img>` HTML tag.
+The `<Img>` tag can be used like a regular `<img>` HTML tag.
If you use `<Img>`, Remotion will ensure that the image is loaded before rendering the frame. That way you can avoid flickers if the image does not load immediately during rendering.
@@ -71,6 +71,12 @@ From `v3.3.82`, the image load will first be retried before `onError` is thrown.
If an image fails to load, it will be retried from `v3.3.82`. The default value is `2`.
An exponential backoff is being used, with 1000ms delay between the first and second attempt, then 2000ms, then 4000ms and so on.
+### `pauseWhenLoading`
+
+_optional_
+
+If set to `true`, pause the Player when the image is loading. See: [Buffer state](/docs/player/buffer-state).
+
## Other props
Remotion inherits the props of the regular `<img>` tag, like for example `style`.
diff --git a/packages/docs/docs/player/buffer-state.mdx b/packages/docs/docs/player/buffer-state.mdx
index a5a89f939c..5e18ecc714 100644
--- a/packages/docs/docs/player/buffer-state.mdx
+++ b/packages/docs/docs/player/buffer-state.mdx
@@ -14,7 +14,8 @@ Remotion has a native buffer state, which can be used to pause the video when th
## TL;DR
-You can add a `pauseWhenBuffering` prop to your [`<Video>`](/docs/video/#pausewhenbuffering), [`<OffthreadVideo>`](/docs/offthreadvideo/#pausewhenbuffering), [`<Audio>`](/docs/audio/#pausewhenbuffering) and [`<Img>`](/docs/img/#pausewhenbuffering) tags.
+You can add a `pauseWhenBuffering` prop to your [`<Video>`](/docs/video/#pausewhenbuffering), [`<OffthreadVideo>`](/docs/offthreadvideo/#pausewhenbuffering), [`<Audio>`](/docs/audio/#pausewhenbuffering) tags.
+The prop is called `pauseWhenLoading` for [`<Img>`](/docs/img/#pausewhenloading) tags.
By doing so, the Player will briefly pause until your media is loaded.
## Mechanic
@@ -165,7 +166,7 @@ a delay</a>, a <a href="/docs/player/buffer-state#indicating-buffering-in-the-ui
You may add additional UI to this, for example by overlaying the Player with a spinner when the Player is buffering.
-## Listening to buffer events
+### Listening to buffer events
If the `<Player />` is entering a buffer state, it will emit the `waiting` event.
Once it resumes, it emits the `resume` event.
@@ -223,10 +224,10 @@ export const App: React.FC = () => {
You can enable buffering on the following components:
-- [`<Audio>`](/docs/audio) - add the `pauseWhenBuffering` props
-- [`<Video>`](/docs/video) - add the `pauseWhenBuffering` props
-- [`<OffthreadVideo>`](/docs/offthreadvideo) - add the `pauseWhenBuffering` props
-- [`<Img>`](/docs/img) // FIXME: How?
+- [`<Audio>`](/docs/audio#pausewhenbuffering) - add the `pauseWhenBuffering` prop
+- [`<Video>`](/docs/video#pausewhenbuffering) - add the `pauseWhenBuffering` prop
+- [`<OffthreadVideo>`](/docs/offthreadvideo#pausewhenloading) - add the `pauseWhenBuffering` prop
+- [`<Img>`](/docs/img#pausewhenloading) - add the `pauseWhenLoading` prop
## Indicating buffering in the UI
@@ -347,7 +348,7 @@ const MyApp: React.FC = () => {
};
```
-## Upcoming changes in future versions
+## Upcoming changes in Remotion 5.0
In Remotion 4.0, media tags such as `<Audio>`, `<OffthreadVideo>` tags will need to opt-in to use the buffer state.
diff --git a/packages/docs/docs/troubleshooting/video-flicker.md b/packages/docs/docs/troubleshooting/video-flicker.md
index 64811d1c49..415d3989c7 100644
--- a/packages/docs/docs/troubleshooting/video-flicker.md
+++ b/packages/docs/docs/troubleshooting/video-flicker.md
@@ -37,7 +37,7 @@ This effect is only happening in the Remotion Studio and the Remotion Player, an
<strong><Step>2</Step>Option 2: Pause the <code>{"<Player/>"}</code> when media is buffering</strong><br/>
-You may want to pause the `<Player>` temporarily to allow loading of the assets and resume once the assets are ready for playback.<br/> You can do so by adding a `pauseWhenBuffering` prop to your [`<Video>`](/docs/video/#pausewhenbuffering), [`<OffthreadVideo>`](/docs/offthreadvideo/#pausewhenbuffering), [`<Audio>`](/docs/audio/#pausewhenbuffering) and [`<Img>`](/docs/img/#pausewhenbuffering) tags. [See here](/docs/player/buffer-state) for how to implement this.
+You may want to pause the `<Player>` temporarily to allow loading of the assets and resume once the assets are ready for playback.<br/> You can do so by adding a `pauseWhenBuffering` prop to your [`<Video>`](/docs/video/#pausewhenbuffering), [`<OffthreadVideo>`](/docs/offthreadvideo/#pausewhenbuffering), [`<Audio>`](/docs/audio/#pausewhenbuffering) and [`<Img>`](/docs/img/#pausewhenbuffering) tags. [Learn more about the buffer state.](/docs/player/buffer-state)
<strong><Step>3</Step>Option 3: Preloading to avoid network request</strong><br/>