0.2.0 • Published 1 year ago

san-lyric v0.2.0

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

san-lyric

 npm install san-lyric --save

1. Methods(方法)

getScreenFps ----> 获取屏幕刷新率

App.tsx 中调用获取 fps 并进行保存,方便后续调用。

getScreenFps?.().then((fps: number) => {
  console.log("当前屏幕刷新率为", fps);
  // todo code
});

2. Components(组件)

Lyric ----> 歌词显示组件

展示歌词的组件

Props

NameDescTypeDefaultRequired
lyrics歌词数据 aLyricItemType[][]true
currentTime歌曲播放当前进度 ms毫秒级number0true
duration歌曲总时长 ms毫秒级number0true
fps屏幕刷新率number0true
color文本颜色Colorfalse
selectColor播放时文本颜色Colorfalse
selectBgColor播放时文本背景颜色Colorfalse

3. Hooks

useLyricData (格式化歌词)

需要传递原文歌词和译文歌词

NameDescTypeDefaultRequired
lyric原文歌词stringtrue
t_lyric译文歌词stringtrue

4. Type(类型)

LyricItemType

NameDescTypeDefaultRequired
lyric原文歌词stringtrue
t_lyric译文歌词stringtrue
time展示当前歌词的时间number0true

Example ( React )

const BaseLyric = memo(({ id, currentTime, duration }: IBaseLyricProps) => {
  // const { data, runAsync } = useRequest(getLyricData, {
  //   manual: true,
  // });

  const lyricData = useLyricData(
    data?.lrc.lyric ?? "",
    data?.romalrc.lyric ?? ""
  );
  useAsyncEffect(async () => {
    if (id !== "") {
      await runAsync(id);
    }
  }, [id]);

  return (
    <div className="lyric-container">
      <Lyric
        lyrics={lyricData ?? []}
        currentTime={currentTime}
        duration={duration}
        fps={60}
      />
    </div>
  );
});
0.2.0

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago

0.0.14

1 year ago

0.0.13

1 year ago

0.0.12

1 year ago

0.0.11

1 year ago

0.0.10

1 year ago

0.0.9

1 year ago

0.0.8

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago