Skip to content

fix: 歌词时间标签小数部分的前导零被丢掉,导致部分行延后显示 - #3048

Merged
lyswhut merged 3 commits into
lyswhut:devfrom
b84330808:fix-lrc-hundredths-leading-zero
Nov 10, 2026
Merged

lyswhut merged 3 commits into
lyswhut:devfrom
b84330808:fix-lrc-hundredths-leading-zero

Conversation

@b84330808

Copy link
Copy Markdown

相关 #2855

line-player.js 在算时间之前先用 formatTimeLabel() 去掉了小数部分的前导零。歌词里没有三位小数的时间标签时(isMsTime 为 false),小数会按百分秒补零,所以 [00:20.05] 先变成 20.5,再补成 500 毫秒,而不是 50 毫秒。小数为 .01~.09 的行都会晚 0.27~0.81 秒显示。

这里改为用原始时间标签计算时间,formatTimeLabel() 的结果仍只作为 linesMap 的 key,翻译和罗马音的匹配不变。三位小数(毫秒)的歌词结果也不变。

用 #2855 里的网易云歌词《不老梦》(全部是两位小数)测试:

行 修改前 修改后
[01:09.08] 69800 ms(+720 ms) 69080 ms
[02:31.03] 151300 ms(+270 ms) 151030 ms

修改后 53 行带文字的歌词全部与标签一致。

b84330808 and others added 3 commits November 8, 2026 02:12
formatTimeLabel() strips leading zeros from the fraction, so [00:20.05]
became 20.5 and was padded to 500 ms instead of 50 ms. Compute the time
from the original label and keep the formatted label only as the map key.
Refactor msTime handling for better formatting.
@lyswhut
lyswhut merged commit c796cde into lyswhut:dev Nov 10, 2026
1 check passed
@lyswhut

lyswhut commented Nov 10, 2026

Copy link
Copy Markdown
Owner

thx!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants