0.1.6 • Published 2 years ago

lyric-resolver v0.1.6

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

LyricParser

Description

A JavaScript plugin for parser Lyric

📦 Install

npm install lyric-resolver

🔋 Features

  • Easy to use: Just play() togglePlay() stop() seek()
  • 🦾 Type Strong: Written in Typescript, with TS Docs

🎄 Example

🦄 Usage

import Lyric, { HandlerParams } from 'lyric-resolver'

import { getLyric } from '../api/lyric.js'

export async function useLyric(): any {
    const lrc = await getLyric()
    const currentLyric = new Lyric(lrc, handleLyric)

    /*
    * @params curLineNum [number] Current line of lyric
    * @params txt [string] Current line's txt
    * 
    * @return void
    * */
    function handleLyric(payload: HandlerParams): void {
        const { curLineNum, txt } = payload
        // You can also get curLineNum like this
        // 你也可以向下面这样操作得到curLineNum
        const curLine: number = currentLyric.curLine
    }

    function play(): void {
        // Start playing
      currentLyric.play()
    }
    function stop(): void {
        // Stop playing
      currentLyric.stop()
    }
    function togglePlay(): void {
        // Auto set play state
      currentLyric.togglePlay()
    }
    function seek(time): void {
        // Reset start time
      currentLyric.seek(time)
    }
}