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

react-lrcplayer

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-lrcplayer

React 带歌词的简易播放器

latest
npmnpm
Version
3.0.10
Version published
Maintainers
1
Created
Source

带LRC歌词的简易播放器

功能

  • 标题副标题显示
  • 封面展示
  • 歌词动画
  • 定义歌词行数
  • 原生audio播放器
  • lrc歌词同步显示(需提前转换为json)

本项目基于React开发,仅在React Vite环境测试通过。

体验:https://os.arsrna.cn/demo/nodejs/lrcplayer

DEMO

克隆本项目,并执行

npm i
npm start

打开localhost:5173即可测试demo

用法

安装

npm i react-lrcplayer

引入

import { LRCPlayer,createLrcObj } from 'react-lrcplayer';
// 全局引用样式
import 'react-lrcplayer/dist/index.css';

示例

在页面中(以example/App.tsx的vite环境为例):

 <LRCPlayer
        src={src}
        cover={cover}
        title="希林娜依高,HOYO-MiX - 烬火 Emberfire"
        subTitle="《原神》动画短片「烬中歌」插曲"
        lrc={lrc}
        placeholder="无歌词"
        offset="-0.3"
        animate={{
          type: "slide",
          duration: 8,
        }}
        nextLrc={{
          display: true,
          number: 2
        }}
    />

API

参数类型内容默认值必填
srcfile / string音频文件URL地址undefined
coverfile / string封面图片文件URLundefined
titlestring / React DOM播放器标题""
subTitlestring / React DOM副标题""
lrcobjectlrc对象,内容见下文undefined
offsetnumber偏移量,正数为延后,负数为提前0
animateobject动画设置,内容见下文{ type: "fade", duration: 0.5 }
nextLrcobject下句歌词显示设置,内容见下文{ display:false, number:5 }

lrc

此参数表示歌词对象,本框架已内置lrc转为对象的功能,如下LRC:

可以直接调用 createLrcObj(lrc歌词原内容)来实现转换

[00:26.446]天气晴 风平浪静 沙滩上混乱的脚印
[00:32.499]钓鱼竿 两份孤单 会飞的落汤鸡
[00:37.725]是故事的开局

转换为对象即为

[{
    "t": 26.446,
    "c": "天气晴 风平浪静 沙滩上混乱的脚印"
  },{
    "t": 32.499,
    "c": "钓鱼竿 两份孤单 会飞的落汤鸡"
  },{
    "t": 37.725,
    "c": "是故事的开局"
}]
参数类型内容
tnumber进入时间点
cstring对应歌词内容

animate

参数类型内容默认值必填
typestring动画类型(划入: slide,淡入: fade,无: none)fade
durationnumber动画持续时间,单位秒0.5

nextLrc

参数类型内容默认值必填
displayboolean是否显示true
numbernumber显示句数2

Keywords

music player

FAQs

Package last updated on 10 Nov 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