The DotLottieController class provides a comprehensive interface for managing the playback and configuration of dotLottie animations within Jetpack Compose. This reference outlines its properties, methods, and the mechanism for event handling.
The DotLottieController provides additional methods for programmatic control in Compose and supports all the same functionality as the traditional UI DotLottieAnimation view.
Properties
Property
Description
Type
Access
isPlaying
Checks if the animation is playing.
Boolean
Read
isLoaded
Determines if the animation has been loaded successfully.
Boolean
Read
isComplete
Checks if the animation has completed playing.
Boolean
Read
isStopped
Indicates whether the animation is stopped.
Boolean
Read
isPaused
Indicates whether the animation is paused.
Boolean
Read
speed
The playback speed of the animation.
Float
Read
loop
Determines whether the animation should loop.
Boolean
Read
autoplay
Determines if the animation will start playing automatically.
Boolean
Read
totalFrames
The total number of frames in the animation.
Float
Read
currentFrame
The current frame of the animation.
Float
Read
playMode
The play mode of the animation (e.g., forward, reverse).
Mode
Read
segment
The start and end frames of the current segment being played.
Pair<Float, Float>?
Read
duration
The duration of the animation in seconds.
Float
Read
loopCount
The number of times the animation will loop.
UInt
Read
useFrameInterpolation
Checks if frame interpolation is enabled for smoother animation.
Boolean
Read
activeThemeId
Retrieves the ID of the currently active theme.
String
Read
activeAnimationId
Retrieves the ID of the currently active animation.
String
Read
Methods
Playback Control
Method
Description
play()
Starts or resumes the animation.
pause()
Pauses the animation.
stop()
Stops the animation and resets to the beginning.
setSpeed(speed: Float)
Sets the playback speed of the animation.
setLoop(loop: Boolean)
Sets whether the animation should loop.
setPlayMode(mode: Mode)
Sets the play mode of the animation (Forward, Reverse, etc.).
Frame Manipulation
Method
Description
setFrame(frame: Float)
Sets the current frame of the animation.
setSegment(firstFrame: Float, lastFrame: Float)
Defines the start and end frames for a segment of the animation to play.
freeze()
Freezes the animation at the current frame.
unFreeze()
Unfreezes the animation, allowing it to continue.
setUseFrameInterpolation(enable: Boolean)
Enables or disables frame interpolation.
Animation Loading and Configuration
Method
Description
loadAnimation(animationId: String)
Loads an animation by its ID from multi-animation .lottie files.
The DotLottieController class allows for the registration of event listeners that implement the DotLottieEventListener interface. These listeners can respond to various animation events, including:
This API reference provides a detailed overview of the DotLottieController class, enabling developers to fully leverage its capabilities for controlling dotLottie animations within their Jetpack Compose applications.