getLottieMetadata()
属于 @remotion/lottie 软件包的一部分.
🌐 Part of the @remotion/lottie package.
使用此功能,你可以获取 Lottie 动画的基本元数据,例如尺寸、时长和帧率。
🌐 Using this function, you can get the basic metadata such as dimensions, duration and framerate of a Lottie animation.
Animation.tsximport {getLottieMetadata } from "@remotion/lottie"; // animationData is a JSON object, can be imported from a .json file, remote file or using staticFile() constmetadata =getLottieMetadata (animationData ); /* { durationInFrames: 90, durationInSeconds: 3.0030030030030037, fps: 29.9700012207031, height: 1080, width: 1920, } */
应用编程接口
🌐 API
该函数接受一个参数,即符合 Lottie 架构的 JavaScript 对象。
🌐 The function takes one argument, a JavaScript object that adheres to the Lottie schema.
返回值
🌐 Return value
如果元数据无法解析,此函数将返回 null。
🌐 If the metadata cannot be parsed, this function returns null.
如果元数据可以被解析,它将返回一个具有以下属性的对象:
🌐 If the metadata can be parsed, it returns an object with the following properties:
height
动画的自然高度(像素)。
🌐 The natural height of the animation in pixels.
width
动画的自然宽度(以像素为单位)。
🌐 The natural width of the animation in pixels.
durationInSeconds
如果使用这个对象的 fps,动画的持续时间(以秒为单位)。
🌐 The duration of the animation in seconds, if the fps from this object is used.
durationInFrames
如果使用这个对象的 fps,动画的帧持续时间。
🌐 The duration of the animation in frames, if the fps from this object is used.
该值被向下取整到最接近的整数,因为 Remotion 不支持 durationInFrames 的非整数值。
fps
Lottie 动画的自然帧率。
🌐 The natural framerate of the Lottie animation.
另请参阅
🌐 See also