🎥 Make videos programmatically with React
mention safari issue
Jonny Burger5f8afd27a092
diff --git a/packages/docs/docs/prefetch.mdx b/packages/docs/docs/prefetch.mdxindex 2a20d6f54e..7d0f77fafc 100644--- a/packages/docs/docs/prefetch.mdx+++ b/packages/docs/docs/prefetch.mdx@@ -2,7 +2,7 @@image: /generated/articles-docs-prefetch.pngid: prefetchtitle: prefetch()-crumb: "API"+crumb: 'API'---_Available in v3.2.23_@@ -15,27 +15,30 @@ If you pass the original URL into either an [`<Audio>`](/docs/audio), [`<Video>`Remote assets need to support [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS).<details>-<summary>More info</summary>-<ul>-<li>-Remotion's origin is usually <code>http://localhost:3000</code>, but it may be different if rendering on Lambda or the port is busy.-</li>-<li>-You can <a href="/docs/chromium-flags#--disable-web-security">disable CORS</a> during renders.-</li>-</ul>+ <summary>More info</summary>+ <ul>+ <li>+ Remotion's origin is usually <code>http://localhost:3000</code>, but it+ may be different if rendering on Lambda or the port is busy.+ </li>+ <li>+ You can{' '}+ <a href="/docs/chromium-flags#--disable-web-security">disable CORS</a>{' '}+ during renders.+ </li>+ </ul></details>:::```tsx twoslash-import { prefetch } from "remotion";+import {prefetch} from 'remotion';-const { free, waitUntilDone } = prefetch("https://example.com/video.mp4", {- method: "blob-url",+const {free, waitUntilDone} = prefetch('https://example.com/video.mp4', {+ method: 'blob-url',});waitUntilDone().then(() => {- console.log("Video has finished loading");+ console.log('Video has finished loading');});// Call free() if you want to un-prefetch and free up the memory:@@ -76,24 +79,24 @@ Set a content type for the blob. By default, the content type from the HTTP respCallback for progress events.```tsx twoslash-import { prefetch } from "remotion";-import type { PrefetchOnProgress } from "remotion";+import {prefetch} from 'remotion';+import type {PrefetchOnProgress} from 'remotion';const onProgress: PrefetchOnProgress = (progress) => {if (progress.totalBytes === null) {// HTTP response has no "Content-Length" header,// therefore no relative progress can be calculated.- console.log("Loaded bytes:", progress.loadedBytes);+ console.log('Loaded bytes:', progress.loadedBytes);return;}console.log(- "Loading progress:",- Math.round(progress.loadedBytes / progress.totalBytes / 100) + "%",+ 'Loading progress:',+ Math.round(progress.loadedBytes / progress.totalBytes / 100) + '%',);};-prefetch("https://example.com/video.mp4", {+prefetch('https://example.com/video.mp4', {onProgress,});```@@ -107,9 +110,11 @@ An object with:Calling this function will abort the prefetching is still in progress and free up the memory. Components using the asset might re-request the asset.### `waitUntilDone()`-Calling this will return a `Promise<string>` that resolves once asset has finished downloading and is ready to be used.++Calling this will return a `Promise<string>` that resolves once asset has finished downloading and is ready to be used.The `string` that is being returned is either:+- A `blob:` URL or `data:` Base 64 data respectively- The same `src` you passed as input, if in a rendering environment.@@ -130,6 +135,8 @@ Files loaded from the internet should be served with a proper content type, e.g.This can lead to the video file not playing correctly in the browser. If you cannot influence the server, you can also set the content type manually using the [`contentType`](#contenttype) option.+This issue may arise in Safari specifically. We recommend testing your implementation in Safari after you coded it.+## See also- [`@remotion/preload`](/docs/preload)