From ee12da741001a3244b1c2744240c6106b435344c Mon Sep 17 00:00:00 2001 From: lrisora <43085437+lrisora@users.noreply.github.com> Date: Fri, 15 Sep 2023 09:16:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E4=B9=8B=E5=89=8D=E7=9A=84?= =?UTF-8?q?=E6=9B=B4=E6=94=B9=E5=AF=BC=E8=87=B4=E7=9A=84=E8=BF=9B=E5=85=A5?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=A4=B9=E6=A8=A1=E5=BC=8F=E6=97=B6=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MusicPlayer2/Player.cpp | 25 ++++++++++--------------- MusicPlayer2/Player.h | 4 ++-- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/MusicPlayer2/Player.cpp b/MusicPlayer2/Player.cpp index 6dbc8ff02..9fd08de45 100644 --- a/MusicPlayer2/Player.cpp +++ b/MusicPlayer2/Player.cpp @@ -310,19 +310,14 @@ void CPlayer::IniPlaylistComplate() item.is_favourite = favourite_playlist.IsSongInPlaylist(item); } - if (!IsPlaying()) - { - //清除歌词和专辑封面 - m_album_cover.Destroy(); - m_album_cover_blur.Destroy(); - m_Lyrics = CLyrics(); - } - - //对播放列表排序 - if (!m_thread_info.is_playlist_mode && m_playlist.size() > 1) - SortPlaylist(false); - ASSERT(m_playing == 0); // 这里应该一定是停止状态,我将之前的旧代码换成了这个断言,有问题的话再改回去 + // 对播放列表排序 + if (!m_thread_info.is_playlist_mode && m_playlist.size() > 1) + SortPlaylist(true); + // 清除歌词和专辑封面 + m_album_cover.Destroy(); + m_album_cover_blur.Destroy(); + m_Lyrics = CLyrics(); // 修正程序启动时系统播放控件的播放状态不正确的问题(改在这里,可被下面的初始化后继续播放重新设置为playing状态) MusicControl(Command::CLOSE); // 这里设置GetSongNum()返回0时的默认SMTC状态 @@ -2214,9 +2209,9 @@ void CPlayer::ReIniPlayerCore(bool replay) GetPlayStatusMutex().unlock(); } -void CPlayer::SortPlaylist(bool change_index) +void CPlayer::SortPlaylist(bool is_init) { - if (m_loading) return; + if (m_loading && !is_init) return; CWaitCursor wait_cursor; SongInfo current_song = GetCurrentSongInfo(); switch (m_sort_mode) @@ -2272,7 +2267,7 @@ void CPlayer::SortPlaylist(bool change_index) break; } - if (change_index) + if (!is_init) // 由初始化完成方法调用时不重新查找index { //播放列表排序后,查找正在播放项目的序号 for (int i{}; i < GetSongNum(); i++) diff --git a/MusicPlayer2/Player.h b/MusicPlayer2/Player.h index 4a27a3433..968628cc3 100644 --- a/MusicPlayer2/Player.h +++ b/MusicPlayer2/Player.h @@ -461,8 +461,8 @@ class CPlayer //重新初始化BASS。当replay为true时,如果原来正在播放,则重新初始化后继续播放 void ReIniPlayerCore(bool replay = false); - //播放列表按照m_sort_mode排序(当change_index为true时,排序后重新查找正在播放的歌曲) - void SortPlaylist(bool change_index = true); + //播放列表按照m_sort_mode排序(当is_init为false时,排序后重新查找正在播放的歌曲) + void SortPlaylist(bool is_init = false); //将整个播放列表倒序 void InvertPlaylist(); //获取专辑封面