preloadGif()
从 v3.3.38 版本开始可用
调用 preloadGif(src)
并传入您想要加载的 GIF 的 URL,GIF 将被准备好以在 <Player>
中显示。
该函数返回一个包含两个条目的对象:waitUntilDone()
返回一个可以等待的 Promise,free()
可以取消预加载或释放内存,如果 GIF 不再被使用。
ts
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 GIFfree ();});
ts
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 GIFfree ();});