From e6d244b249fd2bb7e8704bb013e9ee7dc763f7ed Mon Sep 17 00:00:00 2001 From: MATRIX-feather Date: Sat, 21 Sep 2024 20:55:42 +0800 Subject: [PATCH] bruh --- .../CloudMusic/Misc/StringExtensions.cs | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.IGPlayer/Feature/Player/Plugins/Bundle/CloudMusic/Misc/StringExtensions.cs b/osu.Game.Rulesets.IGPlayer/Feature/Player/Plugins/Bundle/CloudMusic/Misc/StringExtensions.cs index c7a6967..6b3416d 100644 --- a/osu.Game.Rulesets.IGPlayer/Feature/Player/Plugins/Bundle/CloudMusic/Misc/StringExtensions.cs +++ b/osu.Game.Rulesets.IGPlayer/Feature/Player/Plugins/Bundle/CloudMusic/Misc/StringExtensions.cs @@ -11,10 +11,33 @@ public static class StringExtensions public static int ToMilliseconds(this string src) { int result; + string[] spilt = src.Split("."); + + if (spilt.Length < 3) + { + // ??? + Logging.Log($"给定的时间不正确:{src}"); + return int.MaxValue; + } + + string formatString = ""; + + for (int i = 0; i < spilt[0].Length; i++) + formatString += "m"; + + formatString += @"\."; + + for (int i = 0; i < spilt[1].Length; i++) + formatString += "s"; + + formatString += @"\."; + + for (int i = 0; i < spilt[2].Length; i++) + formatString += "f"; try { - var timeSpan = TimeSpan.ParseExact($"{src}", @"mm\.ss\.fff", new DateTimeFormatInfo()); + var timeSpan = TimeSpan.ParseExact($"{src}", formatString, new DateTimeFormatInfo()); result = (int)timeSpan.TotalMilliseconds; } catch (Exception e)