Tweak synchronized lyrics related code in Lyrics
This commit is contained in:
parent
073a50b34c
commit
6a556e8b56
1 changed files with 4 additions and 4 deletions
|
@ -241,19 +241,19 @@ fun Lyrics(
|
|||
|
||||
val synchronizedLyrics = remember(lyrics) {
|
||||
SynchronizedLyrics(KuGou.Lyrics(lyrics).sentences) {
|
||||
player.currentPosition
|
||||
player.currentPosition + 50
|
||||
}
|
||||
}
|
||||
|
||||
val lazyListState = rememberLazyListState(synchronizedLyrics.index, with (density) { size.roundToPx() } / 6)
|
||||
|
||||
LaunchedEffect(synchronizedLyrics) {
|
||||
val center = with (density) { size.roundToPx() } / 6
|
||||
|
||||
while (isActive) {
|
||||
delay(50)
|
||||
if (synchronizedLyrics.update()) {
|
||||
synchronizedLyrics.sentences.getOrNull(synchronizedLyrics.index)?.first?.let {
|
||||
lazyListState.animateScrollToItem(synchronizedLyrics.index, with (density) { size.roundToPx() } / 6)
|
||||
}
|
||||
lazyListState.animateScrollToItem(synchronizedLyrics.index, center)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue