Skip to content

Usage

Parsing Lyrics

The easiest way to parse lyrics is using AutoParser.

val lrcContent = "[00:00.00]Hello World"
val lyrics: SyncedLyrics = AutoParser.parse(lrcContent)

// Access lines
lyrics.lines.forEach { line ->
    println("${line.start} - ${line.content}")
}

// Check for Karaoke data
if (lyrics.lines.first() is KaraokeLine) {
    // Handle syllable data
}

If you know the format explicitly, you can use specific parsers:

val parser = KrcParser()
val lyrics = parser.parse(krcContent)

Exporting Lyrics

To convert a SyncedLyrics object back to a string:

val exporter = LrcExporter()
val lrcString = exporter.export(lyrics)

Creating Lyrics Manually

You can also construct SyncedLyrics programmatically (see Architecture for model details).

val lyrics = SyncedLyrics(
    lines = listOf(
        SyncedLine(0, 1000, "First Line"),
        SyncedLine(1000, 2000, "Second Line")
    )
)