Я сделал пользовательский рендер для LottieUWP
[assembly: ExportRenderer(typeof(LottieView), typeof(LottieViewRenderer))]
namespace Gorilla.Forms.UWP.Source.Renderer.Lottie
{
public class LottieViewRenderer : ViewRenderer<LottieView, LottieAnimationView>
{
private LottieAnimationView AnimationView;
protected override void OnElementChanged(ElementChangedEventArgs<LottieView> e)
{
base.OnElementChanged(e);
if (Control == null)
{
if (e.NewElement == null) return;
AnimationView = new LottieAnimationView()
{
Name = e.NewElement.AnimationPath,
FileName = e.NewElement.AnimationPath,
AutoPlay = true,
RepeatCount = -1
};
SetNativeControl(AnimationView);
}
}
}
}
А вот LottieView
public class LottieView : View
{
public static readonly BindableProperty AnimationPathProperty = BindableProperty.Create(
propertyName: nameof(AnimationPath),
returnType: typeof(string),
declaringType: typeof(LottieView));
public string AnimationPath
{
get => (string)GetValue(AnimationPathProperty);
set => SetValue(AnimationPathProperty, value);
}
}
Это работает, но иногда при зависании или ожиданииЧерез несколько секунд я получаю сообщение об ошибке:
WinRT information: Attempting to close a CanvasActiveLayer that is not top of the stack. The most recently created layer must be closed first.
at System.Runtime.InteropServices.WindowsRuntime.IClosable.Close()
at System.Runtime.InteropServices.WindowsRuntime.IClosableToIDisposableAdapter.Dispose()
at LottieUWP.LottieDrawable.Draw(CanvasDevice device, BitmapCanvas bitmapCanvas, CompositionLayer compositionLayer, Rect bounds, Single scale, Byte alpha, Matrix3X3 matrix, Double width, Double height, CanvasDrawingSession canvasDrawingSession)
at LottieUWP.LottieDrawable.CanvasControlOnDraw(ICanvasAnimatedControl canvasControl, CanvasAnimatedDrawEventArgs args)
at Windows.ApplicationModel.Core.UnhandledError.Propagate()
at Microsoft.AppCenter.Utils.ApplicationLifecycleHelper.<.ctor>b__17_1(Object sender, UnhandledErrorDetectedEventArgs eventArgs)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.AppCenter.Utils.ApplicationLifecycleHelper.<.ctor>b__17_1(Object sender, UnhandledErrorDetectedEventArgs eventArgs)
Кажется, это ошибка внутри LottieUWP или моя реализациянеправильно?