AnimatedVisualPlayer.AnimationOptimization Property

Definition

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

public:
 property PlayerAnimationOptimization AnimationOptimization { PlayerAnimationOptimization get(); void set(PlayerAnimationOptimization value); };
/// [Microsoft.UI.Xaml.CustomAttributes.MUXPropertyChangedCallback(enable=true)]
/// [Microsoft.UI.Xaml.CustomAttributes.MUXPropertyDefaultValue(value="winrt::PlayerAnimationOptimization::Latency")]
/// [get: Microsoft.UI.Xaml.CustomAttributes.MUXPropertyChangedCallback(enable=true)]
/// [get: Microsoft.UI.Xaml.CustomAttributes.MUXPropertyDefaultValue(value="winrt::PlayerAnimationOptimization::Latency")]
/// [set: Microsoft.UI.Xaml.CustomAttributes.MUXPropertyChangedCallback(enable=true)]
/// [set: Microsoft.UI.Xaml.CustomAttributes.MUXPropertyDefaultValue(value="winrt::PlayerAnimationOptimization::Latency")]
PlayerAnimationOptimization AnimationOptimization();

void AnimationOptimization(PlayerAnimationOptimization value);
[Microsoft.UI.Xaml.CustomAttributes.MUXPropertyChangedCallback(enable=true)]
[Microsoft.UI.Xaml.CustomAttributes.MUXPropertyDefaultValue(value="winrt::PlayerAnimationOptimization::Latency")]
public PlayerAnimationOptimization AnimationOptimization { [Microsoft.UI.Xaml.CustomAttributes.MUXPropertyChangedCallback(enable=true)] [Microsoft.UI.Xaml.CustomAttributes.MUXPropertyDefaultValue(value="winrt::PlayerAnimationOptimization::Latency")] get; [Microsoft.UI.Xaml.CustomAttributes.MUXPropertyChangedCallback(enable=true)] [Microsoft.UI.Xaml.CustomAttributes.MUXPropertyDefaultValue(value="winrt::PlayerAnimationOptimization::Latency")] set; }
var playerAnimationOptimization = animatedVisualPlayer.animationOptimization;
animatedVisualPlayer.animationOptimization = playerAnimationOptimization;
Public Property AnimationOptimization As PlayerAnimationOptimization

Property Value

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

Attributes
Microsoft.UI.Xaml.CustomAttributes.MUXPropertyChangedCallbackAttribute Microsoft.UI.Xaml.CustomAttributes.MUXPropertyDefaultValueAttribute

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

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.

Applies to

See also