From 369261c8cf552d2e2fae34ebced4da159b7fe178 Mon Sep 17 00:00:00 2001 From: lrisora <43085437+lrisora@users.noreply.github.com> Date: Sat, 8 May 2021 13:05:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E4=B8=8A=E6=AC=A1=E6=8F=90?= =?UTF-8?q?=E4=BA=A4=E5=BD=93cue=E6=AD=A3=E5=B8=B8=E6=97=B6=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E7=9A=84=E6=96=87=E4=BB=B6=E4=BF=A1=E6=81=AF=E8=A2=AB?= =?UTF-8?q?=E9=87=8D=E7=BD=AE=E7=9A=84=E9=97=AE=E9=A2=98=EF=BC=8C=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E8=AF=86=E5=88=AB=E6=94=AF=E6=8C=81cue=E5=A4=9A?= =?UTF-8?q?=E6=89=A9=E5=B1=95=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MusicPlayer2/AudioCommon.cpp | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/MusicPlayer2/AudioCommon.cpp b/MusicPlayer2/AudioCommon.cpp index fe1791c1..cc60de1d 100644 --- a/MusicPlayer2/AudioCommon.cpp +++ b/MusicPlayer2/AudioCommon.cpp @@ -271,15 +271,15 @@ void CAudioCommon::GetCueTracks(vector& files, IPlayerCore* pPlayerCor CCueFile cue_file{ file_path.GetFilePath() }; wstring audio_file_name; // 临时存储音频文件名 + int bitrate{}; // 比特率 + Time audio_file_length{}; // 音频文件长度 bool audio_file_name_change = true; // 音频文件未匹配,当audio_file_name被错误检查改变,temp[j].file_path不再准确时设为true const std::vector& temp = cue_file.GetAnalysisResult(); // 遍历cue音轨分析对应音频文件,为了处理一个cue对应多个音频的情况有必要遍历 for (int j = 0; j < temp.size(); ++j) { CFilePathHelper audio_file_path{ temp[j].file_path }; - int bitrate{}; - Time audio_file_length{}; - // 连续同一文件不再二次操作 + // audio_file_path正确时连续同一文件不再二次操作 if (audio_file_path.GetFileName() != audio_file_name || audio_file_path.GetFileName().empty()) { audio_file_name = audio_file_path.GetFileName(); @@ -297,15 +297,9 @@ void CAudioCommon::GetCueTracks(vector& files, IPlayerCore* pPlayerCor wstring extension{ file_path.GetFileExtension() }; // 获取文件扩展名 return extension != L"cue" && FileIsAudio(file_name); }); - if (!files.empty()) // 找到了满足要求的文件 + // 如果没有找到则尝试与cue同名音频文件 + while (files.empty()) { - audio_file_name = files.front(); - audio_file_name_change = true; - } - else - { - // 如果没有找到则尝试与cue同名音频文件 - files.clear(); CCommon::GetFiles(cue_dir + file_path.GetFileNameWithoutExtension() + L".*", files, [](const wstring& file_name) { @@ -313,11 +307,15 @@ void CAudioCommon::GetCueTracks(vector& files, IPlayerCore* pPlayerCor wstring extension{ file_path.GetFileExtension() }; // 获取文件扩展名 return extension != L"cue" && FileIsAudio(file_name); }); - if (!files.empty()) // 找到了满足要求的文件 - { - audio_file_name = files.front(); - audio_file_name_change = true; - } + if (file_path.GetFileExtension() != std::wstring()) // 逐个移除扩展名 + file_path.SetFilePath(file_path.GetFilePathWithoutExtension()); + else + break; + } + if (!files.empty()) // 找到了满足要求的文件 + { + audio_file_name = files.front(); + audio_file_name_change = true; } } // 音频不存在处理完成但仍然不能保证成功