Skip to content

React Component for Making and Display Lyrics of A Song

License

Notifications You must be signed in to change notification settings

allape/React-Lyrics

Repository files navigation

React Lyrics

React Component for Making and Display Lyrics of A Song

TODO

  • Basic Mode
  • Karaoke Mode
  • Lyrics Editor
  • Apple Music Style (Almost)

Installation

npm install github:allape/React-Lyrics

Usage

See SimplePlayer for complete demo.

import { Lyrics, TimePoint, useRAFAudioTime } from '@allape/lyrics';
import { ReactElement, useCallback } from 'react';

export function Display({ text, karaoke }: Props): ReactElement {
  const [audio, setAudio] = useState<HTMLAudioElement | null>(null);
  const [current] = useRAFAudioTime(audio);

  const handleChange = useCallback((tp: TimePoint) => {
    if (!audio) {
      return;
    }
    audio.currentTime = tp / 1000;
  }, [audio]);

  return <>
    <auido ref={setAudio} src={url} controls/>
    <Lyrics
            current={current}
            content={text}
            karaoke={karaoke}
            onChange={handleChange}
    />
  </>;
}

Dev

npm install
npm run dev

File Format

See 唐朝乐队 - 国际歌 / Tang Dynasty - L'Internationale for example.

Credits

About

React Component for Making and Display Lyrics of A Song

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published