Share via


AnimatedVisualPlayer.AnimationOptimization 属性

定义

获取或设置一个值,该值指定在 空闲时 AnimatedVisualPlayer 如何缓存动画 (在) 处于非活动状态时 PlayAsync 缓存动画。

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; }
Public Property AnimationOptimization As PlayerAnimationOptimization

属性值

一个 值,该值指定在 处于空闲状态时 AnimatedVisualPlayer 如何缓存动画 (在) 处于非活动状态时 PlayAsync 缓存动画。 默认为 Latency

属性
Microsoft.UI.Xaml.CustomAttributes.MUXPropertyChangedCallbackAttribute Microsoft.UI.Xaml.CustomAttributes.MUXPropertyDefaultValueAttribute

示例

如果动画在单击时开始,请将 属性初始化为 Resources。 然后,当鼠标进入控件时,将 设置为 AnimationOptimizationLatency ,将 设置为 Resources 鼠标离开控件时。 这可确保动画在单击时立即启动,而无需使用不必要的资源。

如果在加载动画之前调用 PlayAsync,则在完全加载所有动画之前,播放器不会启动。

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

注解

如果设置 Source 玩家的 或 AnimationOptimization ,播放器将延迟源文件的处理,直到正在处理布局。

适用于

另请参阅