Skip to content

Commit

Permalink
修复本地歌曲歌词获取问题
Browse files Browse the repository at this point in the history
  • Loading branch information
lyswhut committed Dec 28, 2023
1 parent 1637ae4 commit 2337a3e
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/renderer/core/music/local.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,14 @@ export const getLyricInfo = async({ musicInfo, isRefresh, onToggleSource = () =>
onToggleSource?: (musicInfo?: LX.Music.MusicInfoOnline) => void
}): Promise<LX.Player.LyricInfo> => {
if (!isRefresh) {
const lyricInfo = await getCachedLyricInfo(musicInfo)
if (lyricInfo) {
// 存在已编辑、原始歌词
if (lyricInfo.rawlrcInfo.lyric) return buildLyricInfo(lyricInfo)
const [lyricInfo, fileLyricInfo] = await Promise.all([getCachedLyricInfo(musicInfo), window.lx.worker.main.getMusicFileLyric(musicInfo.meta.filePath)])
if (lyricInfo?.lyric && lyricInfo.lyric != lyricInfo.rawlrcInfo.lyric) {
// 存在已编辑歌词
return buildLyricInfo({ ...lyricInfo, rawlrcInfo: fileLyricInfo ?? lyricInfo.rawlrcInfo })
}

// 尝试读取文件内歌词
const rawlrcInfo = await window.lx.worker.main.getMusicFileLyric(musicInfo.meta.filePath)
if (rawlrcInfo) return buildLyricInfo(lyricInfo ? { ...lyricInfo, rawlrcInfo } : rawlrcInfo)
if (fileLyricInfo) return buildLyricInfo(fileLyricInfo)
if (lyricInfo?.lyric) return buildLyricInfo(lyricInfo)
}

onToggleSource()
Expand Down

0 comments on commit 2337a3e

Please sign in to comment.