Skip to content

Commit

Permalink
修复播放列表双击的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Miaoyww committed Aug 31, 2022
1 parent 6c50cf9 commit d91999a
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 31 deletions.
63 changes: 33 additions & 30 deletions NcmPlayer/Resources/PlaylistMethod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}));
});
}
Expand Down
5 changes: 4 additions & 1 deletion NcmPlayer/Views/Pages/PlaylistBar.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
}

0 comments on commit d91999a

Please sign in to comment.