Пример #1
0
        protected async override Task OnAfterRenderAsync(bool isFirstRender)
        {
            await JSRuntime.InvokeVoidAsync("doUserSelectDir");

            var queryString = QueryHelpers.ParseQuery(new Uri(NavigationManager.Uri).Query);

            ResourceReader = await BeatmapHelper.LoadNetworkResources(94790);

            /*
             * if (queryString.TryGetValue("sid", out var beatmapSetId))
             *  ResourceReader = await BeatmapHelper.LoadNetworkResources(int.Parse(beatmapSetId.ToString()));
             * else
             *  //尝试发起本地上传文件请求
             *  ResourceReader = await BeatmapHelper.LoadLocalResources();
             *
             * if (ResourceReader is null)
             * {
             *  //错误处理
             *  return;
             * }
             */

            Console.WriteLine("Start to select a .osb file and a .osu file (if it exist.)");
            var osbFilePath = ResourceReader.EnumeratePath("*.osb").FirstOrDefault();
            var osuFilePath = ResourceReader.EnumeratePath("*.osu").FirstOrDefault();

            Console.WriteLine("osu file : " + osuFilePath);
            Console.WriteLine("osb file : " + osbFilePath);

            var updater = StoryboardHelper.ParseStoryboard(ResourceReader.ReadFile(osuFilePath), ResourceReader.ReadFile(osbFilePath));

            Console.WriteLine($"Storyboard objects count : {updater.StoryboardObjectList.Count}");

            Console.WriteLine($"Start load render resource...");
            await StoryboardWindow.PrepareRenderResource(updater, ResourceReader);

            Console.WriteLine($"Render resource loading DONE!");

            StoryboardWindow.Play();

            Console.WriteLine($"OnAfterRenderAsync() end");
        }
        static async Task Main(string[] args)
        {
            var bufferSize = 123456;
            var buffer     = ArrayPool <byte> .Shared.Rent(bufferSize);

            var memory = buffer.AsMemory().Slice(0, bufferSize);

            MemoryMarshal.TryGetArray <byte>(memory, out var segment);

            var reader = await BeatmapHelper.LoadNetworkResources(94790);

            Console.WriteLine("Start to select a .osb file and a .osu file (if it exist.)");
            var osbFilePath = reader.EnumeratePath("*.osb").FirstOrDefault();
            var osuFilePath = reader.EnumeratePath("*.osu").FirstOrDefault();


            var updater = StoryboardHelper.ParseStoryboard(reader.ReadFile(osbFilePath), reader.ReadFile(osuFilePath));

            Console.WriteLine(updater.StoryboardObjectList.Count);
        }