Skip to content

Commit

Permalink
feat: Support playback rate on iOS/macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinZikmund committed Mar 25, 2020
1 parent f6e1bf6 commit f21f458
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/AddIns/Uno.UI.Lottie/LottieVisualSource.Android.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ void SetProperties()
if (_lastPath != path)
{
_animation.SetAnimation(path);
_lastPath = path;
}

switch (player.Stretch)
Expand Down
10 changes: 8 additions & 2 deletions src/AddIns/Uno.UI.Lottie/LottieVisualSource.iOSmacOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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);
Expand All @@ -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)
{
Expand All @@ -66,6 +71,7 @@ void SetProperties()
break;
}

_animation.AnimationSpeed = (nfloat)player.PlaybackRate;

if (player.AutoPlay && !_isPlaying)
{
Expand Down

0 comments on commit f21f458

Please sign in to comment.