getGifDurationInSeconds()
属于 @remotion/gif 软件包的一部分
🌐 Part of the @remotion/gif package
获取 GIF 的持续时间(以秒为单位)。
🌐 Gets the duration in seconds of a GIF.
note
远程 GIF 需要支持 CORS。 Remotion 的来源通常是 你可以 在渲染期间禁用 CORS 。更多信息
http://localhost:3000,但如果在 Lambda 上渲染或端口被占用,可能会有所不同。
参数
🌐 Arguments
src
指向 GIF 资源的字符串
🌐 A string pointing to a GIF asset
返回值
🌐 Return value
Promise<number> - GIF 的持续时间,以秒为单位,不考虑它是否循环播放。
示例
🌐 Example
import {getGifDurationInSeconds } from '@remotion/gif';
import gif from './cat.gif';
const MyComp : React .FC = () => {
const getDuration = useCallback (async () => {
const imported = await getGifDurationInSeconds (gif ); // 127.452
const publicFile = await getGifDurationInSeconds (staticFile ('giphy.gif')); // 2.10
const remote = await getGifDurationInSeconds ('https://media.giphy.com/media/xT0GqH01ZyKwd3aT3G/giphy.gif'); // 3.23
}, []);
useEffect (() => {
getDuration ();
}, []);
return null;
};另请参阅
🌐 See also