mirror of
https://github.com/LanZhan-Harmony/WindowsMusicPlayer-TheUntamedMusicPlayer.git
synced 2026-05-06 19:20:18 +08:00
修复灵动词岛崩溃
This commit is contained in:
@@ -45,21 +45,26 @@ public sealed partial class LyricManager(SharedPlaybackState state)
|
||||
/// </summary>
|
||||
public async void GetSongLyric()
|
||||
{
|
||||
CurrentLyricSlices = await LyricParser.GetLyricSlices(
|
||||
var slices = await LyricParser.GetLyricSlices(
|
||||
_state.CurrentSong!.Lyric,
|
||||
_state.CurrentSong!.Duration
|
||||
);
|
||||
CurrentLyricIndex = 0;
|
||||
|
||||
if (CurrentLyricSlices.Count > 0)
|
||||
_dispatcher.TryEnqueue(() =>
|
||||
{
|
||||
CurrentLyricSlices[0].IsCurrent = true;
|
||||
CurrentLyricContent = CurrentLyricSlices[0].Content;
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrentLyricContent = "";
|
||||
}
|
||||
CurrentLyricSlices = slices;
|
||||
CurrentLyricIndex = 0;
|
||||
|
||||
if (CurrentLyricSlices.Count > 0)
|
||||
{
|
||||
CurrentLyricSlices[0].IsCurrent = true;
|
||||
CurrentLyricContent = CurrentLyricSlices[0].Content;
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrentLyricContent = "";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -95,16 +100,23 @@ public sealed partial class LyricManager(SharedPlaybackState state)
|
||||
return;
|
||||
}
|
||||
|
||||
var oldSlice = CurrentLyricSlices[CurrentLyricIndex];
|
||||
var newSlice = CurrentLyricSlices[newIndex];
|
||||
var newContent = newSlice.Content;
|
||||
_dispatcher.TryEnqueue(() =>
|
||||
{
|
||||
oldSlice.IsCurrent = false;
|
||||
if (newIndex < 0 || newIndex >= CurrentLyricSlices.Count)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (CurrentLyricIndex >= 0 && CurrentLyricIndex < CurrentLyricSlices.Count)
|
||||
{
|
||||
CurrentLyricSlices[CurrentLyricIndex].IsCurrent = false;
|
||||
}
|
||||
|
||||
var newSlice = CurrentLyricSlices[newIndex];
|
||||
newSlice.IsCurrent = true;
|
||||
CurrentLyricContent = newContent;
|
||||
CurrentLyricContent = newSlice.Content;
|
||||
CurrentLyricIndex = newIndex;
|
||||
});
|
||||
CurrentLyricIndex = newIndex;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -112,9 +124,12 @@ public sealed partial class LyricManager(SharedPlaybackState state)
|
||||
/// </summary>
|
||||
public void Reset()
|
||||
{
|
||||
CurrentLyricIndex = 0;
|
||||
CurrentLyricContent = "";
|
||||
CurrentLyricSlices.Clear();
|
||||
_dispatcher.TryEnqueue(() =>
|
||||
{
|
||||
CurrentLyricIndex = 0;
|
||||
CurrentLyricContent = "";
|
||||
CurrentLyricSlices.Clear();
|
||||
});
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
||||
@@ -57,13 +57,13 @@
|
||||
<PackageReference Include="ManagedBass.Fx" Version="4.0.2" />
|
||||
<PackageReference Include="ManagedBass.Wasapi" Version="4.0.2" />
|
||||
<PackageReference Include="MemoryPack" Version="1.21.4" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="10.0.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="10.0.3" />
|
||||
<PackageReference Include="Microsoft.Graphics.Win2D" Version="1.3.2" />
|
||||
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.8.260101001" />
|
||||
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.8.260209005" />
|
||||
<PackageReference Include="Microsoft.Xaml.Behaviors.WinUI.Managed" Version="3.0.1" />
|
||||
<PackageReference Include="TagLibSharp" Version="2.3.0" />
|
||||
<PackageReference Include="WinUIEx" Version="2.9.0" />
|
||||
<PackageReference Include="ZLinq" Version="1.5.4" />
|
||||
<PackageReference Include="ZLinq" Version="1.5.5" />
|
||||
<PackageReference Include="ZLogger" Version="2.5.10" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
Reference in New Issue
Block a user