@music-lyric-player/base 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +59 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# @music-lyric-player/base
|
|
2
|
+
|
|
3
|
+
> Headless timing and state engine for `music-lyric-player`.
|
|
4
|
+
|
|
5
|
+
Owns playback time, active-line tracking, and event emission. Pure logic with **zero DOM dependencies** — pair it with [`@music-lyric-player/dom`](https://github.com/music-lyric/music-lyric-player-web/tree/main/packages/dom) for the default renderer, or plug in your own.
|
|
6
|
+
|
|
7
|
+
Part of [music-lyric-player-web](https://github.com/music-lyric/music-lyric-player-web).
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```shell
|
|
12
|
+
npm install @music-lyric-player/base music-lyric-kit
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Events
|
|
16
|
+
|
|
17
|
+
| Event | Payload | Fires when |
|
|
18
|
+
| --- | --- | --- |
|
|
19
|
+
| `play` | `(currentTime: number)` | Playback starts or resumes |
|
|
20
|
+
| `pause` | `(currentTime: number)` | Playback pauses |
|
|
21
|
+
| `lyricUpdate` | `(info: Info)` | A new lyric is loaded |
|
|
22
|
+
| `linesUpdate` | `(lines, indexes, firstIndex, isSeek)` | Active lines change |
|
|
23
|
+
|
|
24
|
+
## Usage
|
|
25
|
+
|
|
26
|
+
```js
|
|
27
|
+
import { BaseLyricPlayer } from '@music-lyric-player/base'
|
|
28
|
+
import { ParserPipeline } from 'music-lyric-kit'
|
|
29
|
+
|
|
30
|
+
const base = new BaseLyricPlayer()
|
|
31
|
+
|
|
32
|
+
base.event.add('play', (time) => {})
|
|
33
|
+
base.event.add('pause', (time) => {})
|
|
34
|
+
base.event.add('lyricUpdate', (info) => {})
|
|
35
|
+
base.event.add('linesUpdate', (lines, indexes, firstIndex, isSeek) => {})
|
|
36
|
+
|
|
37
|
+
const { result } = new ParserPipeline({
|
|
38
|
+
content: { original: '[00:01.114]Hello world' },
|
|
39
|
+
format: 'lrc',
|
|
40
|
+
})
|
|
41
|
+
.parse()
|
|
42
|
+
.pureClean()
|
|
43
|
+
.interludeInsert()
|
|
44
|
+
.spaceInsert()
|
|
45
|
+
.final()
|
|
46
|
+
|
|
47
|
+
base.updateLyric(result)
|
|
48
|
+
base.play(0)
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Options
|
|
52
|
+
|
|
53
|
+
| Field | Type | Default | Description |
|
|
54
|
+
| --- | --- | --- | --- |
|
|
55
|
+
| `driver` | `'animation' \| 'timer'` | `'timer'` | Tick source. `animation` uses `requestAnimationFrame`; `timer` uses `setTimeout(16)` |
|
|
56
|
+
|
|
57
|
+
```js
|
|
58
|
+
base.config.update({ driver: 'animation' })
|
|
59
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@music-lyric-player/base",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"author": "folltoshe",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Music Lyric Player - Base Player",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"@music-lyric-kit/lyric": "^0.4.0"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@music-lyric-player/utils": "^0.
|
|
35
|
+
"@music-lyric-player/utils": "^0.9.0"
|
|
36
36
|
},
|
|
37
37
|
"scripts": {
|
|
38
38
|
"build": "vite build"
|