From e3b7506a657ceae514b79c208dab606630c3a8ff Mon Sep 17 00:00:00 2001 From: yibo Date: Mon, 8 Jun 2026 20:30:55 +0800 Subject: [PATCH] fix(lifelog): 语音列表播放按 audioStartMs 切片,对齐文字 --- lifelog-recorder/app/src/main/kotlin/com/lemon/lifelog/MainActivity.kt | 13 ++++--------- lifelog-recorder/app/src/main/kotlin/com/lemon/lifelog/PersonProfileScreen.kt | 7 ++++++- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lifelog-recorder/app/src/main/kotlin/com/lemon/lifelog/MainActivity.kt b/lifelog-recorder/app/src/main/kotlin/com/lemon/lifelog/MainActivity.kt index 13a0d0f..b6a047e 100644 --- a/lifelog-recorder/app/src/main/kotlin/com/lemon/lifelog/MainActivity.kt +++ b/lifelog-recorder/app/src/main/kotlin/com/lemon/lifelog/MainActivity.kt @@ -637,14 +637,8 @@ private fun TimelineTab( } else { nowPlayingPeriod = null nowPlayingId = row.id - scope.launch { - val seg = withContext(Dispatchers.IO) { repo.segments.get(row.id) } - player.play( - seg?.audioPath ?: row.audioPath, - seg?.audioStartMs ?: 0L, - row.durationMs, - ) { nowPlayingId = null } - } + // SegmentRow 现在带 audioStartMs,直接切片,无需再查 Segment。 + player.play(row.audioPath, row.audioStartMs, row.durationMs) { nowPlayingId = null } } }, ) @@ -687,7 +681,8 @@ private fun TimelineTab( if (nowPlayingId == row.id) { player.stop(); nowPlayingId = null } else { - nowPlayingId = row.id; player.play(row.audioPath) { nowPlayingId = null } + nowPlayingId = row.id + player.play(row.audioPath, row.audioStartMs, row.durationMs) { nowPlayingId = null } } actionRow = null }, diff --git a/lifelog-recorder/app/src/main/kotlin/com/lemon/lifelog/PersonProfileScreen.kt b/lifelog-recorder/app/src/main/kotlin/com/lemon/lifelog/PersonProfileScreen.kt index ec4e4cf..ce816ce 100644 --- a/lifelog-recorder/app/src/main/kotlin/com/lemon/lifelog/PersonProfileScreen.kt +++ b/lifelog-recorder/app/src/main/kotlin/com/lemon/lifelog/PersonProfileScreen.kt @@ -159,7 +159,12 @@ internal fun PersonProfileScreen( items(fAudio, key = { it.id }) { row -> AudioRow(row, playing = playingId == row.id) { if (playingId == row.id) { player.stop(); playingId = null } - else { playingId = row.id; player.play(row.audioPath) { playingId = null } } + else { + playingId = row.id + // 块级管线:turn 是块完整录音里的一段,必须按 audioStartMs+durationMs 切片, + // 否则从头播整块、跟这行的文字对不上。 + player.play(row.audioPath, row.audioStartMs, row.durationMs) { playingId = null } + } } } } -- libgit2 0.21.4