preloadGif()
从 v3.3.38 起可用
🌐 available from v3.3.38
使用 GIF 的 URL 调用 preloadGif(src),GIF 将准备好在 <Player> 中显示。
🌐 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>.
该函数返回一个包含两个条目的对象:waitUntilDone(),返回一个可以被 await 的 Promise;free(),如果 GIF 不再使用,将取消预加载或释放内存。
🌐 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 ();
});另请参阅
🌐 See also