preloadGif()
available from v3.3.38
Call preloadGif(src) with the URL of the GIF that you would like to load and the GIF will be prepared for display in the <Player>.
The function returns an object with two entries: waitUntilDone() that returns a Promise which can be awaited and free() which will cancel preloading or free up the memory if the GIF is not being used anymore.
import { preloadGif } from "@remotion/gif";
const { waitUntilDone , free } = preloadGif (
"https://media.giphy.com/media/xT0GqH01ZyKwd3aT3G/giphy.gif"
);
waitUntilDone ().then (() => {
console .log ("The GIF is now ready to play!");
// Later, free the memory of the GIF
free ();
});Options
requestInit?v4.0.460
Options that are passed to the internal fetch() call when preloading the GIF. This can be used to pass credentials or headers for authenticated GIFs.
Remotion manages the internal signal option itself, so passing a signal in requestInit has no effect.
import { preloadGif } from "@remotion/gif";
preloadGif ("https://example.com/authenticated-gif.gif", {
requestInit : {
credentials : 'include',
},
});