DotLottieController Class (for Composable)

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.

Properties

PropertyDescriptionTypeAccess
isPlayingChecks if the animation is playing.BooleanRead
isLoadedDetermines if the animation has been loaded successfully.BooleanRead
isCompleteChecks if the animation has completed playing.BooleanRead
isStoppedIndicates whether the animation is stopped.BooleanRead
isPausedIndicates whether the animation is paused.BooleanRead
speedThe playback speed of the animation.FloatRead
loopDetermines whether the animation should loop.BooleanRead
autoplayDetermines if the animation will start playing automatically.BooleanRead
totalFramesThe total number of frames in the animation.FloatRead
currentFrameThe current frame of the animation.FloatRead
playModeThe play mode of the animation (e.g., forward, reverse).ModeRead
segmentThe start and end frames of the current segment being played.Pair<Float, Float>?Read
durationThe duration of the animation in seconds.FloatRead
loopCountThe number of times the animation will loop.UIntRead
useFrameInterpolationChecks if frame interpolation is enabled for smoother animation.BooleanRead
activeThemeIdRetrieves the ID of the currently active theme.StringRead
activeAnimationIdRetrieves the ID of the currently active animation.StringRead

Methods

MethodDescription
play()Starts or resumes the animation.
pause()Pauses the animation.
stop()Stops the animation and resets to the beginning.
setPlayerInstance(player: DotLottiePlayer)Sets the DotLottiePlayer instance to be controlled.
resize(width: UInt, height: UInt)Resizes the animation view.
setFrame(frame: Float)Sets the current frame of the animation.
setUseFrameInterpolation(enable: Boolean)Enables or disables frame interpolation.
setSegment(firstFrame: Float, lastFrame: Float)Defines the start and end frames for a segment of the animation to play.
setLoop(loop: Boolean)Sets whether the animation should loop.
freeze()Freezes the animation at the current frame.
unFreeze()Unfreezes the animation, allowing it to continue.
setSpeed(speed: Float)Sets the playback speed of the animation.
setPlayMode(mode: Mode)Sets the play mode of the animation.
addEventListener(listener: DotLottieEventListener)Adds an event listener to receive animation events.
removeEventListener(listener: DotLottieEventListener)Removes an event listener.
loadStateMachine(stateMachineId: String): BooleanLoads a specific state machine.
startStateMachine(): BooleanStarts the state machine.
stopStateMachine(): BooleanStops the state machine.
postEvent(event: Event): BooleanTriggers state machine events.
addStateMachineEventListener(listener: StateMachineEventListener)Adds a listener for state machine transition events.
removeStateMachineEventListener(listener: StateMachineEventListener)Removes a state machine transition event listener.
loadAnimation(animationId: String)Loads an animation by its ID.
setTheme(themeId: String)Loads a theme by its ID.
setThemeData(themeData: String)Loads a theme from the provided theme data
resetTheme()Resets the theme to the default theme.
manifest(): Manifest?Retrieves the dotLottie manifest.
resetTheme()Resets the theme to the default theme.
activeThemeId(): String?Retrieves the ID of the currently active theme.
setThemeData(themeData: String)Loads a theme from the provided theme data.

This documentation now includes all properties and methods from the DotLottieController class, ensuring it is comprehensive and up-to-date.

Event Handling

The DotLottieController class allows for the registration of event listeners that implement the DotLottieEventListener interface. These listeners can respond to various animation events, including:

  • onFrame(frameNo: Float)
  • onPause()
  • onStop()
  • onPlay()
  • onComplete()
  • etc…

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.