From f21f4588be71cb3e199bf9783850dda3a08ec354 Mon Sep 17 00:00:00 2001 From: Martin Zikmund Date: Wed, 25 Mar 2020 18:18:59 +0100 Subject: [PATCH] feat: Support playback rate on iOS/macOS --- src/AddIns/Uno.UI.Lottie/LottieVisualSource.Android.cs | 1 + .../Uno.UI.Lottie/LottieVisualSource.iOSmacOS.cs | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/AddIns/Uno.UI.Lottie/LottieVisualSource.Android.cs b/src/AddIns/Uno.UI.Lottie/LottieVisualSource.Android.cs index 23282d9bd9e1..2710d1392c0d 100644 --- a/src/AddIns/Uno.UI.Lottie/LottieVisualSource.Android.cs +++ b/src/AddIns/Uno.UI.Lottie/LottieVisualSource.Android.cs @@ -53,6 +53,7 @@ void SetProperties() if (_lastPath != path) { _animation.SetAnimation(path); + _lastPath = path; } switch (player.Stretch) diff --git a/src/AddIns/Uno.UI.Lottie/LottieVisualSource.iOSmacOS.cs b/src/AddIns/Uno.UI.Lottie/LottieVisualSource.iOSmacOS.cs index a94f3bc05555..198709855d2c 100644 --- a/src/AddIns/Uno.UI.Lottie/LottieVisualSource.iOSmacOS.cs +++ b/src/AddIns/Uno.UI.Lottie/LottieVisualSource.iOSmacOS.cs @@ -18,6 +18,7 @@ partial class LottieVisualSource public bool UseHardwareAcceleration { get; set; } = true; private bool _isPlaying = false; + private string _lastPath = ""; private AnimatedVisualPlayer _player; private void Update() @@ -33,7 +34,6 @@ public void Update(AnimatedVisualPlayer player) if (_animation == null) { _animation = new LOTAnimationView(); - //_animation.Scale = (float)Scale; SetProperties(); #if __IOS__ player.Add(_animation); @@ -48,7 +48,12 @@ public void Update(AnimatedVisualPlayer player) void SetProperties() { - _animation.SetAnimationNamed(UriSource?.PathAndQuery ?? ""); + var path = UriSource?.PathAndQuery ?? ""; + if (_lastPath != path) + { + _animation.SetAnimationNamed(path); + _lastPath = path; + } switch (player.Stretch) { @@ -66,6 +71,7 @@ void SetProperties() break; } + _animation.AnimationSpeed = (nfloat)player.PlaybackRate; if (player.AutoPlay && !_isPlaying) {