Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/6xingyv/accompanist-lyrics-core/llms.txt

Use this file to discover all available pages before exploring further.

Every lyrics line in Accompanist Lyrics Core implements ISyncedLine, the minimal interface that exposes timing information. SyncedLine is the concrete implementation used for line-level (non-karaoke) lyrics; UncheckedSyncedLine is a lenient variant produced during parsing before validation. Both classes carry the line’s text content, an optional translation string, and the millisecond timestamps that bound the line on the playback timeline.

ISyncedLine

ISyncedLine is the common interface implemented by all line types — including SyncedLine, UncheckedSyncedLine, and the KaraokeLine hierarchy.
interface ISyncedLine {
    val start: Int
    val end: Int
    val duration: Int
}
start
Int
Start time of the line in milliseconds.
end
Int
End time of the line in milliseconds.
duration
Int
Length of the line in milliseconds. Implementations compute this as end - start.

SyncedLine

SyncedLine represents a fully validated, single line of lyrics with millisecond timestamps. The init block enforces end >= start; construction throws IllegalArgumentException if that constraint is violated.
data class SyncedLine(
    val content: String,
    val translation: String?,
    override val start: Int,
    override val end: Int,
) : ISyncedLine {
    override val duration = end - start
    // init: requires end >= start
}

Constructor parameters

content
String
required
The display text of the lyrics line.
translation
String?
An optional translation of the line, or null if no translation is available.
start
Int
required
Start time in milliseconds. Must be less than or equal to end.
end
Int
required
End time in milliseconds. Must be greater than or equal to start; otherwise construction throws IllegalArgumentException.

Properties

content
String
The display text of the lyrics line.
translation
String?
Optional translation string; null when not provided.
start
Int
Start time of the line in milliseconds.
end
Int
End time of the line in milliseconds.
duration
Int
Computed as end - start. Always non-negative due to the init constraint.

Extension method: toKaraokeLine()

fun SyncedLine.toKaraokeLine(): KaraokeLine
Converts this SyncedLine into a KaraokeLine.MainKaraokeLine containing a single KaraokeSyllable that spans the full line duration. The syllable’s content is set to this.content, and alignment is set to KaraokeAlignment.Unspecified.
val syncedLine = SyncedLine(
    content = "Hello world",
    translation = null,
    start = 1000,
    end = 3000
)
val karaokeLine: KaraokeLine = syncedLine.toKaraokeLine()
// karaokeLine.syllables.size == 1
// karaokeLine.syllables[0].content == "Hello world"
// karaokeLine.alignment == KaraokeAlignment.Unspecified

UncheckedSyncedLine

UncheckedSyncedLine is a lenient counterpart to SyncedLine used during parsing. It tolerates end < start by clamping duration to 0 rather than throwing. Call toSyncedLine() once the data is validated to obtain a checked SyncedLine.
data class UncheckedSyncedLine(
    val content: String,
    val translation: String?,
    override val start: Int,
    override val end: Int,
) : ISyncedLine {
    override val duration = (end - start).takeIf { it >= 0 } ?: 0

    fun toSyncedLine(): SyncedLine
}

Constructor parameters

content
String
required
The display text of the lyrics line.
translation
String?
Optional translation string, or null.
start
Int
required
Start time in milliseconds. May be greater than end without throwing.
end
Int
required
End time in milliseconds.

Properties

content
String
The display text of the lyrics line.
translation
String?
Optional translation; null when not provided.
start
Int
Start time in milliseconds.
end
Int
End time in milliseconds.
duration
Int
end - start if non-negative, otherwise 0. Never negative.

Method: toSyncedLine()

fun toSyncedLine(): SyncedLine
Converts this UncheckedSyncedLine to a SyncedLine. The resulting SyncedLine enforces end >= start; call this only after confirming the timestamps are valid, or wrap in a try/catch.
val unchecked = UncheckedSyncedLine(
    content = "Verse one",
    translation = null,
    start = 500,
    end = 2000
)
val checked: SyncedLine = unchecked.toSyncedLine()

Usage examples

Rendering a plain lyrics line

val line: SyncedLine = lyrics.lines.filterIsInstance<SyncedLine>().first()

Text(text = line.content)
line.translation?.let { Text(text = it, style = MaterialTheme.typography.bodySmall) }

Checking whether a line is active

fun SyncedLine.isActive(positionMs: Int): Boolean =
    positionMs in start..end

Upcasting through ISyncedLine

val line: ISyncedLine = lyrics.lines[0]
println("Active window: ${line.start}ms – ${line.end}ms (${line.duration}ms)")

Build docs developers (and LLMs) love