From d91999abe8b3fb1ec226ae6b26b66443409f60e9 Mon Sep 17 00:00:00 2001 From: Miaoywww <375629202@qq.com> Date: Wed, 31 Aug 2022 18:48:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=92=AD=E6=94=BE=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E5=8F=8C=E5=87=BB=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- NcmPlayer/Resources/PlaylistMethod.cs | 63 ++++++++++++----------- NcmPlayer/Views/Pages/PlaylistBar.xaml.cs | 5 +- 2 files changed, 37 insertions(+), 31 deletions(-) diff --git a/NcmPlayer/Resources/PlaylistMethod.cs b/NcmPlayer/Resources/PlaylistMethod.cs index a30352c..d0f295a 100644 --- a/NcmPlayer/Resources/PlaylistMethod.cs +++ b/NcmPlayer/Resources/PlaylistMethod.cs @@ -116,43 +116,46 @@ private void PlaySong(int index) { MainWindow.acc.Dispatcher.BeginInvoke(new Action(() => { - Song song = list[index].Song; - string[] artist = song.Artists; - string name = song.Name; - string artists = string.Empty; - Lrcs songLrc = song.GetLrc; - for (int i = 0; i <= artist.Length - 1; i++) + if (list.Count != 0) { - if (i != artist.Length - 1) + Song song = list[index].Song; + string[] artist = song.Artists; + string name = song.Name; + string artists = string.Empty; + Lrcs songLrc = song.GetLrc; + for (int i = 0; i <= artist.Length - 1; i++) { - artists += artist[i] + "/"; + if (i != artist.Length - 1) + { + artists += artist[i] + "/"; + } + else + { + artists += artist[i]; + } } - else + MemoryStream ms = new(); + Stream songCover = song.Cover; + songCover.CopyTo(ms); + string b64Cover = Convert.ToBase64String(ms.ToArray()); + if (!string.IsNullOrEmpty(b64Cover)) { - artists += artist[i]; + Regediter.Regedit("Song", "SongCover", b64Cover); } - } - MemoryStream ms = new(); - Stream songCover = song.Cover; - songCover.CopyTo(ms); - string b64Cover = Convert.ToBase64String(ms.ToArray()); - if (!string.IsNullOrEmpty(b64Cover)) - { - Regediter.Regedit("Song", "SongCover", b64Cover); - } - ResEntry.songInfo.Cover(new MemoryStream(Convert.FromBase64String(RegGeter.RegGet("Song", "SongCover").ToString()))); - ResEntry.songInfo.FilePath = song.GetMp3(); - MusicPlayer.RePlay(ResEntry.songInfo.FilePath, name, artists); - ResEntry.songInfo.DurationTime = song.DuartionTime; - ResEntry.songInfo.AlbumCoverUrl = song.CoverUrl; - ResEntry.songInfo.AlbumId = song.AlbumId; - ResEntry.songInfo.LrcString = song.GetLrcString; + ResEntry.songInfo.Cover(new MemoryStream(Convert.FromBase64String(RegGeter.RegGet("Song", "SongCover").ToString()))); + ResEntry.songInfo.FilePath = song.GetMp3(); + MusicPlayer.RePlay(ResEntry.songInfo.FilePath, name, artists); + ResEntry.songInfo.DurationTime = song.DuartionTime; + ResEntry.songInfo.AlbumCoverUrl = song.CoverUrl; + ResEntry.songInfo.AlbumId = song.AlbumId; + ResEntry.songInfo.LrcString = song.GetLrcString; - Views.Pages.Player.playerPage.ClearLrc(); - Views.Pages.Player.playerPage.UpdateLrc(songLrc); + Views.Pages.Player.playerPage.ClearLrc(); + Views.Pages.Player.playerPage.UpdateLrc(songLrc); - Index = index; - UpdateIndex(); + Index = index; + UpdateIndex(); + } })); }); } diff --git a/NcmPlayer/Views/Pages/PlaylistBar.xaml.cs b/NcmPlayer/Views/Pages/PlaylistBar.xaml.cs index 4e34694..ea99ce4 100644 --- a/NcmPlayer/Views/Pages/PlaylistBar.xaml.cs +++ b/NcmPlayer/Views/Pages/PlaylistBar.xaml.cs @@ -61,7 +61,10 @@ private void UpdateInfo() private void Playlist_PreviewMouseDoubleClick(object sender, MouseButtonEventArgs e) { - ResEntry.wholePlaylist.Play(Playlist.SelectedIndex); + if (Playlist.SelectedIndex != -1) + { + ResEntry.wholePlaylist.Play(Playlist.SelectedIndex); + } } } } \ No newline at end of file