-api-id | -api-type |
---|---|
P:Microsoft.UI.Xaml.Controls.AnimatedVisualPlayer.AnimationOptimization |
winrt property |
Gets or sets a value that specifies how animations are cached when the AnimatedVisualPlayer
is idle (when PlayAsync
is not active).
A value that specifies how animations are cached when the AnimatedVisualPlayer
is idle (when PlayAsync
is not active). The default is Latency
.
If you set the Source
or AnimationOptimization
of your player, the player will defer processing of the source file until the layout is being processed.
AnimatedVisualPlayer, PlayerAnimationOptimization, Lottie-Windows, Tutorials with code examples
If you have an animation that starts on a click, initialize the property to Resources
. Then, set AnimationOptimization
to Latency
when the mouse enters the control and back to Resources
when the mouse leaves the control. This ensures that the animation starts immediately on click without using resources unnecessarily.
If you call PlayAsync before animations are loaded, then the player won't start until all animations are loaded completely.
private void Player_PointerEntered(object sender, PointerRoutedEventArgs e)
{
myanimatedvisualplayer.AnimationOptimization = AnimationOptimization.Latency;
}
async private void Player_PointerExited(object sender, PointerRoutedEventArgs e)
{
myanimatedvisualplayer.AnimationOptimization = AnimationOptimization.Resources;
}
async private void Player_OnClick(object sender, PointerRoutedEventArgs e)
{
myanimatedvisualplayer.PlayAsync(0.0, 1.0);
}