public void Update(AnimatedVisualPlayer player) { if (_animation == null) { _animation = new LottieAnimationView(Android.App.Application.Context); _animation.EnableMergePathsForKitKatAndAbove(true); _animation.UseHardwareAcceleration(UseHardwareAcceleration); //_animation.Scale = (float)Scale; SetProperties(); player.AddView(_animation); } else { SetProperties(); } void SetProperties() { _animation.SetAnimation(UriSource?.PathAndQuery ?? ""); if (player.AutoPlay && !_isPlaying) { Play(true); } } _player = player; }
public void Update(AnimatedVisualPlayer player) { if (_animation == null) { _animation = new LottieAnimationView(Android.App.Application.Context); _animation.EnableMergePathsForKitKatAndAbove(true); _animation.UseHardwareAcceleration(UseHardwareAcceleration); //_animation.Scale = (float)Scale; SetProperties(); player.AddView(_animation); } else { SetProperties(); } void SetProperties() { var path = UriSource?.PathAndQuery ?? ""; if (path.StartsWith("/")) { path = path.Substring(1); } if (_lastPath != path) { _animation.SetAnimation(path); _lastPath = path; } switch (player.Stretch) { case Windows.UI.Xaml.Media.Stretch.None: _animation.SetScaleType(ImageView.ScaleType.Center); break; case Windows.UI.Xaml.Media.Stretch.Uniform: _animation.SetScaleType(ImageView.ScaleType.CenterInside); break; case Windows.UI.Xaml.Media.Stretch.Fill: _animation.SetScaleType(ImageView.ScaleType.FitXy); break; case Windows.UI.Xaml.Media.Stretch.UniformToFill: _animation.SetScaleType(ImageView.ScaleType.CenterCrop); break; } _animation.Speed = (float)player.PlaybackRate; if (player.AutoPlay && !_isPlaying) { Play(true); } } _player = player; }