https://github.com/lyswhut/lrc-file-parser
Javascript-based lrc file parser
https://github.com/lyswhut/lrc-file-parser
javascipt lrc lyric lyric-parser music-library
Last synced: 3 months ago
JSON representation
Javascript-based lrc file parser
- Host: GitHub
- URL: https://github.com/lyswhut/lrc-file-parser
- Owner: lyswhut
- License: mit
- Created: 2018-09-07T05:08:53.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-04-23T11:29:00.000Z (about 2 years ago)
- Last Synced: 2025-03-11T15:58:54.259Z (3 months ago)
- Topics: javascipt, lrc, lyric, lyric-parser, music-library
- Language: TypeScript
- Homepage:
- Size: 4.08 MB
- Stars: 79
- Watchers: 4
- Forks: 27
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# lrc-file-parser
A lrc file parser based javascript
[demo](https://lyswhut.github.io/lrc-file-parser/dist/index.html)
## Installation
- Use npm install
```bash
# install
npm install lrc-file-parser
``````js
// import
import Lyric from 'lrc-file-parser'
```- Use script link
```html
```
## How to use
```js
var lrc = new Lyric({
onPlay: function (line, text) { // Listening play event
console.log(line, text) // line is line number of current play
// text is lyric text of current play line
},
onSetLyric: function (lines) { // listening lyrics seting event
console.log(lines) // lines is array of all lyric text
},
offset: 150, // offset time(ms), default is 150 ms
playbackRate: 1, // playback rate, default is 1
isRemoveBlankLine: true // is remove blank line, default is true
})var extendedLyricStrs = [translationLyricStr]
lrc.setLyric(lyricStr, extendedLyricStrs) // set lyric, lyricStr is lyric file text, extendedLyricStrs is extended lyric file text array (optional)
// note: Setting the lyrics will automatically pause the lyrics playback
lrc.play(30000) // play lyric, 30000 is curent play time, unit: ms
lrc.pause() // pause lyriclrc.setPlaybackRate(1.2) // set playback rate to 1.2x
```
## CHANGELOG
See [CHANGELOG.md](https://github.com/lyswhut/lrc-file-parser/blob/master/CHANGELOG.md)
## LICENSE
MIT