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
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
Method | Description |
---|---|
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): Boolean | Loads a specific state machine. |
startStateMachine(): Boolean | Starts the state machine. |
stopStateMachine(): Boolean | Stops the state machine. |
postEvent(event: Event): Boolean | Triggers 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.