Skip to content

Latest commit

 

History

History
45 lines (33 loc) · 1.94 KB

animatedvisualplayer_animationoptimization.md

File metadata and controls

45 lines (33 loc) · 1.94 KB
-api-id -api-type
P:Microsoft.UI.Xaml.Controls.AnimatedVisualPlayer.AnimationOptimization
winrt property

Microsoft.UI.Xaml.Controls.AnimatedVisualPlayer.AnimationOptimization

-description

Gets or sets a value that specifies how animations are cached when the AnimatedVisualPlayer is idle (when PlayAsync is not active).

-property-value

A value that specifies how animations are cached when the AnimatedVisualPlayer is idle (when PlayAsync is not active). The default is Latency.

-remarks

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.

-see-also

AnimatedVisualPlayer, PlayerAnimationOptimization, Lottie-Windows, Tutorials with code examples

-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);
}