Skip to content

🎥 Make videos programmatically with React

Docs: Improve documentation about `volume`

Jonny Burger6b955c66d03e
diff --git a/packages/docs/docs/audio.mdx b/packages/docs/docs/audio.mdx
index 71b0af59ec..e50aa6b9aa 100644
--- a/packages/docs/docs/audio.mdx
+++ b/packages/docs/docs/audio.mdx
@@ -29,13 +29,24 @@ export const MyVideo = () => {
The component also accepts a `volume` props which allows you to control the volume of the audio in it's entirety or frame by frame. Read the page on [using audio](/docs/using-audio) to learn more.
-```tsx twoslash
-import { AbsoluteFill, Audio, interpolate, staticFile } from "remotion";
+```tsx twoslash title="Setting a static volume"
+import { AbsoluteFill, Audio, staticFile } from "remotion";
export const MyVideo = () => {
return (
<AbsoluteFill>
<Audio volume={0.5} src={staticFile("background.mp3")} />
+ </AbsoluteFill>
+ );
+};
+```
+
+```tsx twoslash title="Changing the volume over time"
+import { AbsoluteFill, Audio, interpolate, staticFile } from "remotion";
+
+export const MyVideo = () => {
+ return (
+ <AbsoluteFill>
<Audio
volume={(f) =>
interpolate(f, [0, 30], [0, 1], { extrapolateLeft: "clamp" })
@@ -47,6 +58,11 @@ export const MyVideo = () => {
};
```
+:::note
+On iOS Safari, it's not possible to granularly change the volume of a media tag.
+Only values `0` and `1` will be respected by the browser.
+:::
+
### `loopVolumeCurveBehavior`<AvailableFrom v="4.0.142" />
Controls the `frame` which is returned when using the [`volume`](#volume) callback function and adding the [`loop`](#loop) attribute.
diff --git a/packages/docs/docs/offthreadvideo.mdx b/packages/docs/docs/offthreadvideo.mdx
index a27ef98d58..fb5f27bb2e 100644
--- a/packages/docs/docs/offthreadvideo.mdx
+++ b/packages/docs/docs/offthreadvideo.mdx
@@ -97,6 +97,34 @@ export const MyComposition = () => {
};
```
+```tsx twoslash title="Example of a ramp up over 100 frames"
+import {
+ AbsoluteFill,
+ interpolate,
+ staticFile,
+ OffthreadVideo,
+} from "remotion";
+
+// ---cut---
+export const MyComposition = () => {
+ return (
+ <AbsoluteFill>
+ <OffthreadVideo
+ volume={(f) =>
+ interpolate(f, [0, 100], [0, 1], { extrapolateLeft: "clamp" })
+ }
+ src={staticFile("video.webm")}
+ />
+ </AbsoluteFill>
+ );
+};
+```
+
+:::note
+On iOS Safari, it's not possible to granularly change the volume of a media tag.
+Only values `0` and `1` will be respected by the browser.
+:::
+
### `loopVolumeCurveBehavior`<AvailableFrom v="4.0.142" />
Controls the `frame` which is returned when using the [`volume`](#volume) callback function and wrapping `OffthreadVideo` in a [`<Loop>`](/docs/loop).
diff --git a/packages/docs/docs/video.mdx b/packages/docs/docs/video.mdx
index 2137f810e1..541bc29d9d 100644
--- a/packages/docs/docs/video.mdx
+++ b/packages/docs/docs/video.mdx
@@ -5,9 +5,11 @@ id: video
crumb: "API"
---
-This component allows you to include a video file in your Remotion project. It wraps the native [`HTMLVideoElement`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLVideoElement).
+Wraps the native [`<video>`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLVideoElement) element to include video in your component that is synchronized with Remotion's time.
-Prefer [`<OffthreadVideo>`](/docs/offthreadvideo) by default which is faster during rendering.
+:::info
+Prefer [`<OffthreadVideo>`](/docs/offthreadvideo) which during render is faster and supports more codecs.
+:::
## API
@@ -108,7 +110,7 @@ export const MyComposition = () => {
};
```
-```tsx twoslash title="Example of a fade in over 100 frames"
+```tsx twoslash title="Example of a ramp up over 100 frames"
import { AbsoluteFill, interpolate, staticFile, Video } from "remotion";
// ---cut---
@@ -126,6 +128,11 @@ export const MyComposition = () => {
};
```
+:::note
+On iOS Safari, it's not possible to granularly change the volume of a media tag.
+Only values `0` and `1` will be respected by the browser.
+:::
+
### `loopVolumeCurveBehavior`<AvailableFrom v="4.0.142" />
Controls the `frame` which is returned when using the [`volume`](#volume) callback function and adding the [`loop`](#loop) attribute.