Skip to content

Commit

Permalink
修正之前的更改导致的进入文件夹模式时没有排序
Browse files Browse the repository at this point in the history
  • Loading branch information
lrisora committed Sep 15, 2023
1 parent 95d2fbe commit ee12da7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 17 deletions.
25 changes: 10 additions & 15 deletions MusicPlayer2/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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状态

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -2272,7 +2267,7 @@ void CPlayer::SortPlaylist(bool change_index)
break;
}

if (change_index)
if (!is_init) // 由初始化完成方法调用时不重新查找index
{
//播放列表排序后,查找正在播放项目的序号
for (int i{}; i < GetSongNum(); i++)
Expand Down
4 changes: 2 additions & 2 deletions MusicPlayer2/Player.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
//获取专辑封面
Expand Down

0 comments on commit ee12da7

Please sign in to comment.