diff --git a/samples/SkiaSharpDemo/Demos/Lottie/LottiePage.xaml b/samples/SkiaSharpDemo/Demos/Lottie/LottiePage.xaml index 76bc247..05905b1 100644 --- a/samples/SkiaSharpDemo/Demos/Lottie/LottiePage.xaml +++ b/samples/SkiaSharpDemo/Demos/Lottie/LottiePage.xaml @@ -8,7 +8,7 @@ LoadAnimationAsync(CancellationTok if (stream is null) throw new FileLoadException($"Unable to load Lottie animation file \"{File}\"."); - var animation = Skottie.Animation.Create(stream); + var animation = CreateAnimationBuilder().Build(stream); if (animation is null) throw new FileLoadException($"Unable to parse Lottie animation \"{File}\"."); diff --git a/source/SkiaSharp.Extended.UI.Maui/Controls/Lottie/SKLottieImageSource.shared.cs b/source/SkiaSharp.Extended.UI.Maui/Controls/Lottie/SKLottieImageSource.shared.cs index ae8ec4d..8a62e36 100644 --- a/source/SkiaSharp.Extended.UI.Maui/Controls/Lottie/SKLottieImageSource.shared.cs +++ b/source/SkiaSharp.Extended.UI.Maui/Controls/Lottie/SKLottieImageSource.shared.cs @@ -1,4 +1,5 @@ - +using SkiaSharp.Resources; + namespace SkiaSharp.Extended.UI.Controls; [TypeConverter(typeof(Converters.SKLottieImageSourceConverter))] @@ -10,6 +11,11 @@ public abstract class SKLottieImageSource : Element public abstract Task LoadAnimationAsync(CancellationToken cancellationToken = default); + internal Skottie.AnimationBuilder CreateAnimationBuilder() => + Skottie.Animation.CreateBuilder() + .SetResourceProvider(new CachingResourceProvider(new DataUriResourceProvider())) + .SetFontManager(SKFontManager.Default); + public static object FromUri(Uri uri) => new SKUriLottieImageSource { Uri = uri }; diff --git a/source/SkiaSharp.Extended.UI.Maui/Controls/Lottie/SKStreamLottieImageSource.shared.cs b/source/SkiaSharp.Extended.UI.Maui/Controls/Lottie/SKStreamLottieImageSource.shared.cs index e7068b9..0332b56 100644 --- a/source/SkiaSharp.Extended.UI.Maui/Controls/Lottie/SKStreamLottieImageSource.shared.cs +++ b/source/SkiaSharp.Extended.UI.Maui/Controls/Lottie/SKStreamLottieImageSource.shared.cs @@ -23,7 +23,7 @@ public override async Task LoadAnimationAsync(CancellationTok if (stream is null) throw new FileLoadException($"Unable to load Lottie animation stream."); - var animation = Skottie.Animation.Create(stream); + var animation = CreateAnimationBuilder().Build(stream); if (animation is null) throw new FileLoadException($"Unable to parse Lottie animation."); diff --git a/source/SkiaSharp.Extended.UI.Maui/Controls/Lottie/SKUriLottieImageSource.shared.cs b/source/SkiaSharp.Extended.UI.Maui/Controls/Lottie/SKUriLottieImageSource.shared.cs index 7ec62be..efd84ad 100644 --- a/source/SkiaSharp.Extended.UI.Maui/Controls/Lottie/SKUriLottieImageSource.shared.cs +++ b/source/SkiaSharp.Extended.UI.Maui/Controls/Lottie/SKUriLottieImageSource.shared.cs @@ -30,7 +30,7 @@ public override async Task LoadAnimationAsync(CancellationTok if (stream is null) throw new FileLoadException($"Unable to load Lottie animation uri \"{Uri}\"."); - var animation = Skottie.Animation.Create(stream); + var animation = CreateAnimationBuilder().Build(stream); if (animation is null) throw new FileLoadException($"Unable to parse Lottie animation \"{Uri}\".");