fix: last line of lyrics is incorrect

This commit is contained in:
Gary Wang 2024-09-26 00:03:26 +08:00
parent 4b57dda342
commit a2b9f94015
No known key found for this signature in database
GPG Key ID: 5D30A4F15EA78760

View File

@ -123,12 +123,12 @@ void LyricsManager::updateCurrentTimeMs(int curTimeMs, int totalTimeMs)
if (!hasLyrics()) return; if (!hasLyrics()) return;
// TODO: we don't need to find from the top everytime the time is updated // TODO: we don't need to find from the top everytime the time is updated
auto iter = std::find_if(m_timestampList.begin(), m_timestampList.end() + 1, [&curTimeMs, this](int timestamp) -> bool { auto iter = std::find_if(m_timestampList.begin(), m_timestampList.end(), [&curTimeMs, this](int timestamp) -> bool {
return (timestamp + m_timeOffset) > curTimeMs; return (timestamp + m_timeOffset) > curTimeMs;
}); });
m_nextLyricsTime = (iter == m_timestampList.end() + 1) ? totalTimeMs : *iter; m_nextLyricsTime = iter == m_timestampList.end() ? totalTimeMs : *iter;
if (iter != m_timestampList.begin() && iter != (m_timestampList.end() + 1)) { if (iter != m_timestampList.begin()) {
iter--; iter--;
} }
m_currentLyricsTime = *iter; m_currentLyricsTime = *iter;