Skip to main content
Use this API to create a context object for controlling Lottie animation playback.

Parameters

PropertyTypeRequiredDescription
lottieIdStringYesID of the lottie component

Return Value

Returns a LottieContext object with playback control methods.

LottieContext Methods

MethodDescription
play()Start animation
pause()Pause animation
stop()Stop animation
setSpeed(speed)Set playback speed

Code Example

const lottieContext = my.createLottieContext('myLottie');

lottieContext.play();

// Pause after 2 seconds
setTimeout(() => {
  lottieContext.pause();
}, 2000);
<lottie id="myLottie" path="animation.json" autoplay="{{false}}" />