Edit

AnimatedVisualPlayer

The AnimatedVisualPlayer control plays vector-based animations in a WinUI 3 app. It is designed for Lottie animations — high-quality, scalable animations created in Adobe After Effects or other applications and exported to JSON format.

Use AnimatedVisualPlayer when you need full programmatic control over playback: play, pause, stop, reverse, loop, or seek to a specific frame. For animations tied to visual state changes (like hover effects on buttons), use AnimatedIcon instead.

Prerequisites

To use Lottie animations with AnimatedVisualPlayer, you need:

  • The Lottie-Windows NuGet package from the Windows Community Toolkit
  • A Lottie JSON file exported from Adobe After Effects (or a compatible tool)
  • The LottieGen tool to convert the JSON file into a C# or C++/WinRT class

The LottieGen tool takes a .json Lottie file as input and generates a class that implements IAnimatedVisualSource. You then reference that class in XAML as the animation source.

Add an animated visual player

Place an AnimatedVisualPlayer in XAML and set its source to the generated Lottie class:

<AnimatedVisualPlayer x:Name="Player" AutoPlay="False">
    <animatedvisuals:LottieLogo1/>
</AnimatedVisualPlayer>

Where animatedvisuals is the XML namespace for the namespace containing your generated Lottie class.

Set AutoPlay="True" if you want the animation to start immediately when the control loads.

Control playback

Use the PlayAsync, Pause, Resume, and Stop methods to control the animation:

// Play the animation forward
Player.PlaybackRate = 1;
await Player.PlayAsync(fromProgress: 0, toProgress: 1, looped: false);

// Pause and resume
Player.Pause();
Player.Resume();

// Stop and reset to the first frame
Player.Stop();

// Play in reverse
Player.PlaybackRate = -1;
await Player.PlayAsync(fromProgress: 1, toProgress: 0, looped: false);

The PlaybackRate property is live — you can change it while an animation is playing. A value of 1 plays forward at normal speed; -1 plays in reverse.

Note

Calling Pause does not complete the PlayAsync task. Call Stop to complete it and reset to the initial frame.

Loop an animation

To play an animation in a continuous loop, set the looped parameter on PlayAsync to true:

await Player.PlayAsync(fromProgress: 0, toProgress: 1, looped: true);

Is this the right control?

Use AnimatedVisualPlayer when you need:

  • Full control over animation playback (play, pause, stop, reverse, seek)
  • Looping animations that run independently of control state
  • Animations that play once in response to a one-time event

Use AnimatedIcon instead when:

  • The animation responds to visual state transitions (hover, pressed, focused)
  • You are adding an icon to a control that accepts IconElement or IconElementSource
WinUI 3 Gallery icon The WinUI 3 Gallery app includes interactive examples of WinUI controls and features. Get the app from the Microsoft Store or browse the source code on GitHub.