Class SKLottiePlayer
A platform-agnostic Skottie (Lottie) animation player that manages playback state and rendering. Can be used directly from any .NET host including .NET MAUI, Blazor, console apps, or custom renderers.
public class SKLottiePlayer
- Inheritance
-
SKLottiePlayer
- Inherited Members
Remarks
Typical usage:
- Create a player and set Repeat and AnimationSpeed.
- Call SetAnimation(Animation?) with a loaded Animation.
- On each frame tick, call Update(TimeSpan) with the elapsed time.
- Call Render(SKCanvas, SKRect) inside your paint/draw callback.
The player is not thread-safe; all calls should occur on the same thread (typically the UI thread).
Constructors
Properties
- AnimationSpeed
Gets or sets the playback speed multiplier. 1.0 = normal speed, 2.0 = double speed, 0.5 = half speed, negative = reverse.
- Duration
Gets the total duration of the loaded animation.
- HasAnimation
Gets whether an animation is currently loaded.
- IsComplete
Gets whether the animation has completed all repeats.
- Progress
Gets the current playback position.
Methods
- Render(SKCanvas, SKRect)
Renders the current animation frame to the given canvas within the specified rectangle.
- Seek(TimeSpan)
Seeks the animation to the specified position and raises AnimationUpdated. Completion and repeat logic is applied as part of the seek.
- SetAnimation(Animation?)
Sets the animation to play. Pass null to clear the current animation. Resets playback state (Progress, IsComplete, repeat counters).
- Update(TimeSpan)
Advances the animation by the given time delta, applying AnimationSpeed and Repeat. Call this on each frame tick.
Events
- AnimationCompleted
Fires when the animation completes all repeats.
- AnimationUpdated
Fires after each Seek(TimeSpan) call, notifying subscribers of updated state (Progress, Duration, IsComplete).