New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

lyrica

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lyrica

Lyrica is a lightweight and optimized JavaScript library for working with both standard and advanced `.lrc` lyric files — perfect for music players, karaoke apps, or any project that needs lyric synchronization and `.lrc` data extraction.

latest
Source
npmnpm
Version
1.0.6
Version published
Maintainers
1
Created
Source

🎵 Lyrica.js

Lyrica is a lightweight and optimized JavaScript library for working with both standard and advanced .lrc lyric files — perfect for music players, karaoke apps, or any project that needs lyric synchronization and .lrc data extraction.

preview

✨ Features

  • Modes:

    • Sync - Render lyrics and synchronize them in real time with an HTML <audio> element.

    • Print - Render lyrics from .lrc files without syncing.

    • Extract - Parse .lrc files to get structured lyric, timing, and metadata data.

  • Animations - Two styles: normal (static) and slide. Optional auto-scroll, wheel/touch scroll handling, and click-to-seek.

  • Full-control - Start, pause, next, previous, go to a specific lyric/time, retrieve current lyric info in real-time.

  • Search - Find a lyric by time or find the timestamp(s) for a given lyric.

📦 Installation

via npm

npm i lyrica

Manual

Download Lyrica.umd.js from dist folder and include it in your project:

<script src="./Lyrica.umd.js"></script>

☄️ Quick Start

HTML:

<audio id="my-audio" src="song.mp3" controls></audio>
<div class="lyrica-container"></div>

JavaScript

const example = new Lyrica("./example.lrc", {
    type: "sync",
    audio_selector: "#my-audio",
    container_selector: ".lyrica-container",
    animations: {
        animation_type: "slide",
        auto_scroll: true
    }
});

🏫 Basic Usage

Path

The first parameter is a string that can be either a .lrc file path or raw .lrc text. (required)

Options

The second parameter is an options object that configures the class.(required)

OptionTypeDefaultDescription
typestring-"sync", "print, "extract" (required)
isRawbooleanfalsePass raw .lrc text instead of file path
offsetnumberinset .lrc offset / 0Adjust lyric timing in millisecond
audio_selectorstring-CSS selector for <audio> element (required for "sync")
container_selectorstring-CSS selector for lyrics container (required for "sync")
animationsobject-Animation settings (see below)
isKaraokebooleanfalseEnable advanced timing parse
actKaraokebooleanisKaraoke's valueWhether to actively display karaoke segment

Animations

KeyTypeDefaultDescription
animation_typestring"normal""normal" or "slide"
auto_scrollbooleanfalseAutomatically scroll to the active lyric (only in "slide")
wheel_scrollbooleantrueEnable mouse-wheel scrolling within sync scroll constraints (only in "slide")
touch_scrollbooleantrueEnable touch scrolling within sync scroll constraints (only in "slide")
change_onclickbooleantrueClicking a lyric seeks audio (only in "slide")
keyframe_idstring"LyricaLyricIn"The name of a CSS keyframe animation that will be applied only when a lyric becomes active in "normal" mode.
animation_parametersstring'ease-out 0.2s'Additional parameters passed to the animation call

Options Object Structure

{
  type: "sync" | "print" | "extract", // Required
  audio_selector: "#audio", // Required for "sync" type
  container_selector: "#lyrics", // Required for "sync" and "print" types
  isKaraoke: false, // Optional
  actKaraoke: false, // Optional
  isRaw: false, // Optional
  autoStart: true, // Optional
  offset: 0, // Optional
  animations: { // Optional
    animation_type: "normal" | "slide",
    animation_parameters: "ease-out 0.2s",
    keyframe_id: "LyricaLyricIn",
    auto_scroll: true,
    wheel_scroll: true,
    touch_scroll: true
  }
}

Methods

Constructor and Static Methods

MethodParametersDescriptionExample
constructor(path, options)path: String
options: Object
Initializes a new Lyrica instance with the given LRC file path and optionsnew Lyrica("lyrics.lrc", {type: "sync"})
static load(path, options)path: String
options: Object
Asynchronously creates and initializes a Lyrica instanceawait Lyrica.load("lyrics.lrc", {type: "sync"})

Core Methods

MethodParametersReturn ValueDescriptionExample
getData()NoneObjectReturns all lyrics data including times, lyrics text, and metadataexample.getData()
getCurrent()NoneArrayReturns current lyric info [text, time, index]. Only works in "sync" modeexample.getCurrent()
start()NoneNoneStarts syncing lyrics with audio. Only works in "sync" modeexample.start()
pause()NoneNonePauses lyric syncing. Only works in "sync" modeexample.pause()

Navigation Methods

MethodParametersReturn ValueDescriptionExample
next(distance)distance: Number (optional)Array/undefinedJumps to next lyric. Returns [text, time, index] or undefinedexample.next() or example.next(2)
previous(distance)distance: Number (optional)Array/undefinedJumps to previous lyric. Returns [text, time, index] or undefinedexample.previous() or example.previous(2)
last()NoneArray/undefinedReturns to last played lyric. Returns [text, time, index] or undefinedexample.last()

Search Methods

MethodParametersReturn ValueDescriptionExample
searchLyric(time, exact, index)time: String/Number
exact: Boolean
index: Boolean
ArrayFinds lyrics by timestampexample.searchLyric("1:30.00", false, true)
searchTime(lyric, index)lyric: String
index: Boolean
ArrayFinds timestamp(s) for given lyric textexample.searchTime("Hello", true)
goTo(place)place: ObjectArray/undefinedJumps to specific position by time, lyric text, or indexexample.goTo({time: "1:30.00"})

CSS Classes

  • Each lyric line is rendered inside an element with the class .lyric (applies to both normal and slide modes).
  • Active state:
    • In slide mode: the current line or current word (in karaoke) receives the .active class.
    • In normal mode: only the current word receives the .active class.
  • Passed lines: any line that has already been played is marked with the .passed class. (only in "slide")
  • Tag types:
    • By default (no karaoke), each line is a <p> element in both normal and slide modes.
    • When isKaraoke: true and actKaraoke: true, each word inside the line is wrapped in a <span> for fine-grained karaoke highlighting.
  • In karaoke + actKaraoke, the line itself still has the .lyric class, but instead of plain text, its words are split into <span>s so timing can highlight each word individually.

🎁 Support This Project

If you find this project useful and would like to support its journey, consider sending a small donation— I’d be truly grateful. ✨

EVM Wallet (MetaMask):

0x22aDc02620D92973705F0274F6b0A5D8718b54B7

- ✅ Supports Ethereum, Polygon, BNB Chain, and other EVM networks

Bitcoin:

bc1ql3p5a9fgssrqqsu4mf6ckqk4xxkn74p6gqpqj9

📝 License

MIT License © mahan-ameri

Keywords

lyrics

FAQs

Package last updated on 18 Sep 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts