Пример #1
0
        internal static async Task <AnimatedVisualFactory?> LoadAsync(
            ImageAssetHandler?imageLoader,
            StorageFile file,
            LottieVisualOptions options)
        {
            if (file is null)
            {
                return(null);
            }

            if (file.Name.EndsWith(".lottie", StringComparison.OrdinalIgnoreCase))
            {
                // It's a .lottie file. Defer to the DotLottieLoader.
                return(await DotLottieLoader.LoadAsync(file, options));
            }

            var loader = new StorageFileLoader(imageLoader, file);

            return(await Loader.LoadAsync(
                       loader.GetJsonStreamAsync,
                       loader,
                       options));
        }
Пример #2
0
        static async Task <AnimatedVisualFactory?> LoadAsync(
            string fileName,
            Stream stream,
            LottieVisualOptions options)
        {
            ZipArchive zipArchive;

            try
            {
                zipArchive = new ZipArchive(stream, ZipArchiveMode.Read);
            }
            catch (InvalidDataException)
            {
                // Not a valid zip file.
                return(null);
            }

            var loader = new DotLottieLoader();

            return(await Loader.LoadAsync(
                       () => loader.GetJsonStreamAsync(zipArchive, fileName),
                       loader,
                       options));
        }