@applemusic-like-lyrics/react 0.3.2 → 0.4.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 +1 -1
- package/dist/amll-react.cjs +228 -0
- package/dist/amll-react.cjs.map +1 -0
- package/dist/amll-react.d.cts +225 -0
- package/dist/amll-react.d.mts +225 -0
- package/dist/{amll-react.js → amll-react.mjs} +3 -3
- package/dist/amll-react.mjs.map +1 -0
- package/package.json +61 -73
- package/LICENSE +0 -661
- package/dist/amll-react.js.map +0 -1
- package/dist/bg-render.d.ts +0 -77
- package/dist/index.d.ts +0 -2
- package/dist/lyric-player.d.ts +0 -144
package/README.md
CHANGED
|
@@ -36,7 +36,7 @@ yarn add @applemusic-like-lyrics/react # using yarn
|
|
|
36
36
|
|
|
37
37
|
For detailed API documentation, please refer to [./docs/modules.md](./docs/modules.md)
|
|
38
38
|
|
|
39
|
-
A test program can be found in [
|
|
39
|
+
A test program can be found in [../playground/react/src/test.tsx](../playground/react/src/test.tsx).
|
|
40
40
|
|
|
41
41
|
```tsx
|
|
42
42
|
import { LyricPlayer } from "@applemusic-like-lyrics/react";
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
let _applemusic_like_lyrics_core = require("@applemusic-like-lyrics/core");
|
|
3
|
+
let react = require("react");
|
|
4
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
5
|
+
let react_dom = require("react-dom");
|
|
6
|
+
//#region src/bg-render.tsx
|
|
7
|
+
/**
|
|
8
|
+
* 流体背景渲染组件,通过提供图片链接可以显示出酷似 Apple Music 的流体背景效果
|
|
9
|
+
*/
|
|
10
|
+
const BackgroundRender = (0, react.forwardRef)(({ album, albumIsVideo, fps, playing, flowSpeed, renderScale, staticMode, lowFreqVolume, hasLyric, renderer, style, ...props }, ref) => {
|
|
11
|
+
const coreBGRenderRef = (0, react.useRef)(null);
|
|
12
|
+
const wrapperRef = (0, react.useRef)(null);
|
|
13
|
+
const lastRendererRef = (0, react.useRef)(null);
|
|
14
|
+
const curRenderer = renderer ?? _applemusic_like_lyrics_core.MeshGradientRenderer;
|
|
15
|
+
(0, react.useEffect)(() => {
|
|
16
|
+
if (lastRendererRef.current !== curRenderer || coreBGRenderRef.current === void 0) {
|
|
17
|
+
lastRendererRef.current = curRenderer;
|
|
18
|
+
coreBGRenderRef.current?.dispose();
|
|
19
|
+
coreBGRenderRef.current = _applemusic_like_lyrics_core.BackgroundRender.new(curRenderer);
|
|
20
|
+
}
|
|
21
|
+
}, [curRenderer]);
|
|
22
|
+
(0, react.useEffect)(() => {
|
|
23
|
+
if (curRenderer && album) coreBGRenderRef.current?.setAlbum(album, albumIsVideo);
|
|
24
|
+
}, [
|
|
25
|
+
curRenderer,
|
|
26
|
+
album,
|
|
27
|
+
albumIsVideo
|
|
28
|
+
]);
|
|
29
|
+
(0, react.useEffect)(() => {
|
|
30
|
+
if (curRenderer && fps) coreBGRenderRef.current?.setFPS(fps);
|
|
31
|
+
}, [curRenderer, fps]);
|
|
32
|
+
(0, react.useEffect)(() => {
|
|
33
|
+
if (!curRenderer) return;
|
|
34
|
+
if (playing === void 0) coreBGRenderRef.current?.resume();
|
|
35
|
+
else if (playing) coreBGRenderRef.current?.resume();
|
|
36
|
+
else coreBGRenderRef.current?.pause();
|
|
37
|
+
}, [curRenderer, playing]);
|
|
38
|
+
(0, react.useEffect)(() => {
|
|
39
|
+
if (!curRenderer) return;
|
|
40
|
+
if (flowSpeed) coreBGRenderRef.current?.setFlowSpeed(flowSpeed);
|
|
41
|
+
}, [curRenderer, flowSpeed]);
|
|
42
|
+
(0, react.useEffect)(() => {
|
|
43
|
+
if (!curRenderer) return;
|
|
44
|
+
coreBGRenderRef.current?.setStaticMode(staticMode ?? false);
|
|
45
|
+
}, [curRenderer, staticMode]);
|
|
46
|
+
(0, react.useEffect)(() => {
|
|
47
|
+
if (curRenderer && renderScale) coreBGRenderRef.current?.setRenderScale(renderScale ?? .5);
|
|
48
|
+
}, [curRenderer, renderScale]);
|
|
49
|
+
(0, react.useEffect)(() => {
|
|
50
|
+
if (curRenderer && lowFreqVolume) coreBGRenderRef.current?.setLowFreqVolume(lowFreqVolume ?? 1);
|
|
51
|
+
}, [curRenderer, lowFreqVolume]);
|
|
52
|
+
(0, react.useEffect)(() => {
|
|
53
|
+
if (curRenderer && hasLyric !== void 0) coreBGRenderRef.current?.setHasLyric(hasLyric ?? true);
|
|
54
|
+
}, [curRenderer, hasLyric]);
|
|
55
|
+
(0, react.useEffect)(() => {
|
|
56
|
+
if (coreBGRenderRef.current) {
|
|
57
|
+
const el = coreBGRenderRef.current.getElement();
|
|
58
|
+
el.style.width = "100%";
|
|
59
|
+
el.style.height = "100%";
|
|
60
|
+
el.style.minHeight = "0";
|
|
61
|
+
el.style.minWidth = "0";
|
|
62
|
+
el.style.overflow = "hidden";
|
|
63
|
+
wrapperRef.current?.appendChild(el);
|
|
64
|
+
}
|
|
65
|
+
}, [coreBGRenderRef.current]);
|
|
66
|
+
(0, react.useImperativeHandle)(ref, () => ({
|
|
67
|
+
wrapperEl: wrapperRef.current,
|
|
68
|
+
bgRender: coreBGRenderRef.current
|
|
69
|
+
}), [wrapperRef.current, coreBGRenderRef.current]);
|
|
70
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
71
|
+
style: {
|
|
72
|
+
display: "contents",
|
|
73
|
+
...style
|
|
74
|
+
},
|
|
75
|
+
...props,
|
|
76
|
+
ref: wrapperRef
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
//#endregion
|
|
80
|
+
//#region src/lyric-player.tsx
|
|
81
|
+
/**
|
|
82
|
+
* 歌词播放组件,本框架的核心组件
|
|
83
|
+
*
|
|
84
|
+
* 尽可能贴切 Apple Music for iPad 的歌词效果设计,且做了力所能及的优化措施
|
|
85
|
+
*/
|
|
86
|
+
const LyricPlayer = (0, react.forwardRef)(({ disabled, playing, alignAnchor, alignPosition, enableSpring, enableBlur, enableScale, maskObsceneWordsMode, maskObsceneWordChar, hidePassedLines, lyricLines, currentTime, isSeeking, wordFadeWidth, linePosXSpringParams, linePosYSpringParams, lineScaleSpringParams, bottomLine, lyricPlayer, onLyricLineClick, onLyricLineContextMenu, ...props }, ref) => {
|
|
87
|
+
const [corePlayer, setCorePlayer] = (0, react.useState)();
|
|
88
|
+
const wrapperRef = (0, react.useRef)(null);
|
|
89
|
+
const currentTimeRef = (0, react.useRef)(currentTime);
|
|
90
|
+
(0, react.useLayoutEffect)(() => {
|
|
91
|
+
const newPlayer = new (lyricPlayer ?? _applemusic_like_lyrics_core.LyricPlayer)();
|
|
92
|
+
setCorePlayer(newPlayer);
|
|
93
|
+
wrapperRef.current?.appendChild(newPlayer.getElement());
|
|
94
|
+
return () => {
|
|
95
|
+
newPlayer?.dispose();
|
|
96
|
+
setCorePlayer(void 0);
|
|
97
|
+
};
|
|
98
|
+
}, [lyricPlayer]);
|
|
99
|
+
(0, react.useLayoutEffect)(() => {
|
|
100
|
+
if (lyricLines !== void 0) {
|
|
101
|
+
corePlayer?.setLyricLines(lyricLines, currentTimeRef.current);
|
|
102
|
+
corePlayer?.update();
|
|
103
|
+
} else {
|
|
104
|
+
corePlayer?.setLyricLines([]);
|
|
105
|
+
corePlayer?.update();
|
|
106
|
+
}
|
|
107
|
+
}, [corePlayer, lyricLines]);
|
|
108
|
+
(0, react.useEffect)(() => {
|
|
109
|
+
if (!disabled) {
|
|
110
|
+
let canceled = false;
|
|
111
|
+
let lastTime = -1;
|
|
112
|
+
const onFrame = (time) => {
|
|
113
|
+
if (canceled) return;
|
|
114
|
+
if (lastTime === -1) lastTime = time;
|
|
115
|
+
corePlayer?.update(time - lastTime);
|
|
116
|
+
lastTime = time;
|
|
117
|
+
requestAnimationFrame(onFrame);
|
|
118
|
+
};
|
|
119
|
+
corePlayer?.calcLayout();
|
|
120
|
+
requestAnimationFrame(onFrame);
|
|
121
|
+
return () => {
|
|
122
|
+
canceled = true;
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
}, [corePlayer, disabled]);
|
|
126
|
+
(0, react.useEffect)(() => {
|
|
127
|
+
if (playing !== void 0) if (playing) corePlayer?.resume();
|
|
128
|
+
else corePlayer?.pause();
|
|
129
|
+
else corePlayer?.resume();
|
|
130
|
+
}, [corePlayer, playing]);
|
|
131
|
+
(0, react.useEffect)(() => {
|
|
132
|
+
if (alignAnchor !== void 0) corePlayer?.setAlignAnchor(alignAnchor);
|
|
133
|
+
}, [corePlayer, alignAnchor]);
|
|
134
|
+
(0, react.useEffect)(() => {
|
|
135
|
+
if (hidePassedLines !== void 0) corePlayer?.setHidePassedLines(hidePassedLines);
|
|
136
|
+
}, [corePlayer, hidePassedLines]);
|
|
137
|
+
(0, react.useEffect)(() => {
|
|
138
|
+
if (alignPosition !== void 0) corePlayer?.setAlignPosition(alignPosition);
|
|
139
|
+
}, [corePlayer, alignPosition]);
|
|
140
|
+
(0, react.useEffect)(() => {
|
|
141
|
+
if (enableSpring !== void 0) corePlayer?.setEnableSpring(enableSpring);
|
|
142
|
+
else corePlayer?.setEnableSpring(true);
|
|
143
|
+
}, [corePlayer, enableSpring]);
|
|
144
|
+
(0, react.useEffect)(() => {
|
|
145
|
+
if (enableScale !== void 0) corePlayer?.setEnableScale(enableScale);
|
|
146
|
+
else corePlayer?.setEnableScale(true);
|
|
147
|
+
}, [corePlayer, enableScale]);
|
|
148
|
+
(0, react.useEffect)(() => {
|
|
149
|
+
corePlayer?.setEnableBlur(enableBlur ?? true);
|
|
150
|
+
}, [corePlayer, enableBlur]);
|
|
151
|
+
(0, react.useEffect)(() => {
|
|
152
|
+
if (currentTime !== void 0) {
|
|
153
|
+
corePlayer?.setCurrentTime(currentTime, isSeeking);
|
|
154
|
+
currentTimeRef.current = currentTime;
|
|
155
|
+
} else corePlayer?.setCurrentTime(0);
|
|
156
|
+
}, [
|
|
157
|
+
corePlayer,
|
|
158
|
+
currentTime,
|
|
159
|
+
isSeeking
|
|
160
|
+
]);
|
|
161
|
+
(0, react.useEffect)(() => {
|
|
162
|
+
corePlayer?.setIsSeeking(!!isSeeking);
|
|
163
|
+
}, [corePlayer, isSeeking]);
|
|
164
|
+
(0, react.useEffect)(() => {
|
|
165
|
+
corePlayer?.setWordFadeWidth(wordFadeWidth);
|
|
166
|
+
}, [corePlayer, wordFadeWidth]);
|
|
167
|
+
(0, react.useEffect)(() => {
|
|
168
|
+
if (linePosXSpringParams !== void 0) corePlayer?.setLinePosXSpringParams(linePosXSpringParams);
|
|
169
|
+
}, [corePlayer, linePosXSpringParams]);
|
|
170
|
+
(0, react.useEffect)(() => {
|
|
171
|
+
if (linePosYSpringParams !== void 0) corePlayer?.setLinePosYSpringParams(linePosYSpringParams);
|
|
172
|
+
}, [corePlayer, linePosYSpringParams]);
|
|
173
|
+
(0, react.useEffect)(() => {
|
|
174
|
+
if (lineScaleSpringParams !== void 0) corePlayer?.setLineScaleSpringParams(lineScaleSpringParams);
|
|
175
|
+
}, [corePlayer, lineScaleSpringParams]);
|
|
176
|
+
(0, react.useEffect)(() => {
|
|
177
|
+
if (maskObsceneWordsMode !== void 0) corePlayer?.setMaskObsceneWords(maskObsceneWordsMode);
|
|
178
|
+
else corePlayer?.setMaskObsceneWords(_applemusic_like_lyrics_core.MaskObsceneWordsMode.Disabled);
|
|
179
|
+
}, [corePlayer, maskObsceneWordsMode]);
|
|
180
|
+
(0, react.useEffect)(() => {
|
|
181
|
+
if (maskObsceneWordChar !== void 0) corePlayer?.setMaskObsceneWordChar(maskObsceneWordChar);
|
|
182
|
+
}, [corePlayer, maskObsceneWordChar]);
|
|
183
|
+
(0, react.useEffect)(() => {
|
|
184
|
+
if (onLyricLineClick) {
|
|
185
|
+
const handler = (e) => onLyricLineClick(e);
|
|
186
|
+
corePlayer?.addEventListener("line-click", handler);
|
|
187
|
+
return () => corePlayer?.removeEventListener("line-click", handler);
|
|
188
|
+
}
|
|
189
|
+
}, [corePlayer, onLyricLineClick]);
|
|
190
|
+
(0, react.useEffect)(() => {
|
|
191
|
+
if (onLyricLineContextMenu) {
|
|
192
|
+
const handler = (e) => onLyricLineContextMenu(e);
|
|
193
|
+
corePlayer?.addEventListener("line-contextmenu", handler);
|
|
194
|
+
return () => corePlayer?.removeEventListener("line-contextmenu", handler);
|
|
195
|
+
}
|
|
196
|
+
}, [corePlayer, onLyricLineContextMenu]);
|
|
197
|
+
(0, react.useImperativeHandle)(ref, () => ({
|
|
198
|
+
wrapperEl: wrapperRef.current,
|
|
199
|
+
lyricPlayer: corePlayer
|
|
200
|
+
}), [corePlayer]);
|
|
201
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
202
|
+
...props,
|
|
203
|
+
ref: wrapperRef
|
|
204
|
+
}), corePlayer?.getBottomLineElement() && bottomLine ? (0, react_dom.createPortal)(bottomLine, corePlayer?.getBottomLineElement()) : null] });
|
|
205
|
+
});
|
|
206
|
+
//#endregion
|
|
207
|
+
exports.BackgroundRender = BackgroundRender;
|
|
208
|
+
Object.defineProperty(exports, "BaseRenderer", {
|
|
209
|
+
enumerable: true,
|
|
210
|
+
get: function() {
|
|
211
|
+
return _applemusic_like_lyrics_core.BaseRenderer;
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
exports.LyricPlayer = LyricPlayer;
|
|
215
|
+
Object.defineProperty(exports, "MeshGradientRenderer", {
|
|
216
|
+
enumerable: true,
|
|
217
|
+
get: function() {
|
|
218
|
+
return _applemusic_like_lyrics_core.MeshGradientRenderer;
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
Object.defineProperty(exports, "PixiRenderer", {
|
|
222
|
+
enumerable: true,
|
|
223
|
+
get: function() {
|
|
224
|
+
return _applemusic_like_lyrics_core.PixiRenderer;
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
//# sourceMappingURL=amll-react.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"amll-react.cjs","names":["MeshGradientRenderer","CoreBackgroundRender","DefaultLyricPlayer","MaskObsceneWordsMode"],"sources":["../src/bg-render.tsx","../src/lyric-player.tsx"],"sourcesContent":["import {\n\ttype AbstractBaseRenderer,\n\ttype BaseRenderer,\n\tBackgroundRender as CoreBackgroundRender,\n\tMeshGradientRenderer,\n} from \"@applemusic-like-lyrics/core\";\nimport {\n\ttype ForwardRefExoticComponent,\n\tforwardRef,\n\ttype HTMLProps,\n\ttype RefAttributes,\n\tuseEffect,\n\tuseImperativeHandle,\n\tuseRef,\n} from \"react\";\n\nexport {\n\tBaseRenderer,\n\tMeshGradientRenderer,\n\tPixiRenderer,\n} from \"@applemusic-like-lyrics/core\";\n\n/**\n * 背景渲染组件的属性\n */\nexport interface BackgroundRenderProps {\n\t/**\n\t * 设置背景专辑资源\n\t */\n\talbum?: string | HTMLImageElement | HTMLVideoElement;\n\t/**\n\t * 设置专辑资源是否为视频\n\t */\n\talbumIsVideo?: boolean;\n\t/**\n\t * 设置当前背景动画帧率,如果为 `undefined` 则默认为 `30`\n\t */\n\tfps?: number;\n\t/**\n\t * 设置当前播放状态,如果为 `undefined` 则默认为 `true`\n\t */\n\tplaying?: boolean;\n\t/**\n\t * 设置当前动画流动速度,如果为 `undefined` 则默认为 `2`\n\t */\n\tflowSpeed?: number;\n\t/**\n\t * 设置背景是否根据“是否有歌词”这个特征调整自身效果,例如有歌词时会变得更加活跃\n\t *\n\t * 部分渲染器会根据这个特征调整自身效果\n\t *\n\t * 如果不确定是否需要赋值或无法知晓是否包含歌词,请传入 true 或不做任何处理(默认值为 true)\n\t */\n\thasLyric?: boolean;\n\t/**\n\t * 设置低频的音量大小,范围在 80hz-120hz 之间为宜,取值范围在 [0.0-1.0] 之间\n\t *\n\t * 部分渲染器会根据音量大小调整背景效果(例如根据鼓点跳动)\n\t *\n\t * 如果无法获取到类似的数据,请传入 undefined 或 1.0 作为默认值,或不做任何处理(默认值即 1.0)\n\t */\n\tlowFreqVolume?: number;\n\t/**\n\t * 设置当前渲染缩放比例,如果为 `undefined` 则默认为 `0.5`\n\t */\n\trenderScale?: number;\n\t/**\n\t * 是否启用静态模式,即图片在更换后就会保持静止状态并禁用更新,以节省性能\n\t * 默认为 `false`\n\t */\n\tstaticMode?: boolean;\n\t/**\n\t * 设置渲染器,如果为 `undefined` 则默认为 `PixiRenderer`\n\t * 默认渲染器有可能会随着版本更新而更换\n\t */\n\trenderer?: {\n\t\tnew (...args: ConstructorParameters<typeof BaseRenderer>): BaseRenderer;\n\t};\n}\n\n/**\n * 背景渲染组件的引用\n */\nexport interface BackgroundRenderRef {\n\t/**\n\t * 背景渲染实例引用\n\t */\n\tbgRender?: AbstractBaseRenderer;\n\t/**\n\t * 将背景渲染实例的元素包裹起来的 DIV 元素实例\n\t */\n\twrapperEl: HTMLDivElement | null;\n}\n\n/**\n * 流体背景渲染组件,通过提供图片链接可以显示出酷似 Apple Music 的流体背景效果\n */\nexport const BackgroundRender: ForwardRefExoticComponent<\n\tOmit<HTMLProps<HTMLDivElement> & BackgroundRenderProps, \"ref\"> &\n\t\tRefAttributes<BackgroundRenderRef>\n> = forwardRef<\n\tBackgroundRenderRef,\n\tHTMLProps<HTMLDivElement> & BackgroundRenderProps\n>(\n\t(\n\t\t{\n\t\t\talbum,\n\t\t\talbumIsVideo,\n\t\t\tfps,\n\t\t\tplaying,\n\t\t\tflowSpeed,\n\t\t\trenderScale,\n\t\t\tstaticMode,\n\t\t\tlowFreqVolume,\n\t\t\thasLyric,\n\t\t\trenderer,\n\t\t\tstyle,\n\t\t\t...props\n\t\t},\n\t\tref,\n\t) => {\n\t\tconst coreBGRenderRef = useRef<AbstractBaseRenderer>(null);\n\t\tconst wrapperRef = useRef<HTMLDivElement>(null);\n\t\tconst lastRendererRef = useRef<{\n\t\t\tnew (canvas: HTMLCanvasElement): BaseRenderer;\n\t\t}>(null);\n\t\tconst curRenderer = renderer ?? MeshGradientRenderer;\n\n\t\tuseEffect(() => {\n\t\t\tif (\n\t\t\t\tlastRendererRef.current !== curRenderer ||\n\t\t\t\tcoreBGRenderRef.current === undefined\n\t\t\t) {\n\t\t\t\tlastRendererRef.current = curRenderer;\n\t\t\t\tcoreBGRenderRef.current?.dispose();\n\t\t\t\tcoreBGRenderRef.current = CoreBackgroundRender.new(curRenderer);\n\t\t\t}\n\t\t}, [curRenderer]);\n\n\t\tuseEffect(() => {\n\t\t\tif (curRenderer && album)\n\t\t\t\tcoreBGRenderRef.current?.setAlbum(album, albumIsVideo);\n\t\t}, [curRenderer, album, albumIsVideo]);\n\n\t\tuseEffect(() => {\n\t\t\tif (curRenderer && fps) coreBGRenderRef.current?.setFPS(fps);\n\t\t}, [curRenderer, fps]);\n\n\t\tuseEffect(() => {\n\t\t\tif (!curRenderer) return;\n\t\t\tif (playing === undefined) {\n\t\t\t\tcoreBGRenderRef.current?.resume();\n\t\t\t} else if (playing) {\n\t\t\t\tcoreBGRenderRef.current?.resume();\n\t\t\t} else {\n\t\t\t\tcoreBGRenderRef.current?.pause();\n\t\t\t}\n\t\t}, [curRenderer, playing]);\n\n\t\tuseEffect(() => {\n\t\t\tif (!curRenderer) return;\n\t\t\tif (flowSpeed) coreBGRenderRef.current?.setFlowSpeed(flowSpeed);\n\t\t}, [curRenderer, flowSpeed]);\n\n\t\tuseEffect(() => {\n\t\t\tif (!curRenderer) return;\n\t\t\tcoreBGRenderRef.current?.setStaticMode(staticMode ?? false);\n\t\t}, [curRenderer, staticMode]);\n\n\t\tuseEffect(() => {\n\t\t\tif (curRenderer && renderScale)\n\t\t\t\tcoreBGRenderRef.current?.setRenderScale(renderScale ?? 0.5);\n\t\t}, [curRenderer, renderScale]);\n\n\t\tuseEffect(() => {\n\t\t\tif (curRenderer && lowFreqVolume)\n\t\t\t\tcoreBGRenderRef.current?.setLowFreqVolume(lowFreqVolume ?? 1.0);\n\t\t}, [curRenderer, lowFreqVolume]);\n\n\t\tuseEffect(() => {\n\t\t\tif (curRenderer && hasLyric !== undefined)\n\t\t\t\tcoreBGRenderRef.current?.setHasLyric(hasLyric ?? true);\n\t\t}, [curRenderer, hasLyric]);\n\n\t\t// biome-ignore lint/correctness/useExhaustiveDependencies: coreBGRenderRef.current\n\t\tuseEffect(() => {\n\t\t\tif (coreBGRenderRef.current) {\n\t\t\t\tconst el = coreBGRenderRef.current.getElement();\n\t\t\t\tel.style.width = \"100%\";\n\t\t\t\tel.style.height = \"100%\";\n\t\t\t\tel.style.minHeight = \"0\";\n\t\t\t\tel.style.minWidth = \"0\";\n\t\t\t\tel.style.overflow = \"hidden\";\n\t\t\t\twrapperRef.current?.appendChild(el);\n\t\t\t}\n\t\t}, [coreBGRenderRef.current]);\n\n\t\t// biome-ignore lint/correctness/useExhaustiveDependencies: wrapperRef.current, coreBGRenderRef.current\n\t\tuseImperativeHandle(\n\t\t\tref,\n\t\t\t() => ({\n\t\t\t\twrapperEl: wrapperRef.current,\n\t\t\t\tbgRender: coreBGRenderRef.current!,\n\t\t\t}),\n\t\t\t[wrapperRef.current, coreBGRenderRef.current],\n\t\t);\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\tstyle={{\n\t\t\t\t\tdisplay: \"contents\",\n\t\t\t\t\t...style,\n\t\t\t\t}}\n\t\t\t\t{...props}\n\t\t\t\tref={wrapperRef}\n\t\t\t/>\n\t\t);\n\t},\n);\n","import type {\n\tLyricLine,\n\tLyricLineMouseEvent,\n\tLyricPlayerBase,\n\tspring,\n} from \"@applemusic-like-lyrics/core\";\nimport {\n\tLyricPlayer as DefaultLyricPlayer,\n\tMaskObsceneWordsMode,\n} from \"@applemusic-like-lyrics/core\";\nimport {\n\ttype ForwardRefExoticComponent,\n\tforwardRef,\n\ttype HTMLProps,\n\ttype RefAttributes,\n\tuseEffect,\n\tuseImperativeHandle,\n\tuseLayoutEffect,\n\tuseRef,\n\tuseState,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\n\n/**\n * 歌词播放组件的属性\n */\nexport interface LyricPlayerProps {\n\t/**\n\t * 是否禁用歌词播放组件,默认为 `false`,歌词组件启用后将会开始逐帧更新歌词的动画效果,并对传入的其他参数变更做出反馈。\n\t *\n\t * 如果禁用了歌词组件动画,你也可以通过引用取得原始渲染组件实例,手动逐帧调用其 `update` 函数来更新动画效果。\n\t */\n\tdisabled?: boolean;\n\t/**\n\t * 是否演出部分效果,目前会控制播放间奏点的动画的播放暂停与否,默认为 `true`\n\t */\n\tplaying?: boolean;\n\t/**\n\t * 设置歌词行的对齐方式,如果为 `undefined` 则默认为 `center`\n\t *\n\t * - 设置成 `top` 的话将会向目标歌词行的顶部对齐\n\t * - 设置成 `bottom` 的话将会向目标歌词行的底部对齐\n\t * - 设置成 `center` 的话将会向目标歌词行的垂直中心对齐\n\t */\n\talignAnchor?: \"top\" | \"bottom\" | \"center\";\n\t/**\n\t * 设置默认的歌词行对齐位置,相对于整个歌词播放组件的大小位置,如果为 `undefined`\n\t * 则默认为 `0.5`\n\t *\n\t * 可以设置一个 `[0.0-1.0]` 之间的任意数字,代表组件高度由上到下的比例位置\n\t */\n\talignPosition?: number;\n\t/**\n\t * 设置是否使用物理弹簧算法实现歌词动画效果,默认启用\n\t *\n\t * 如果启用,则会通过弹簧算法实时处理歌词位置,但是需要性能足够强劲的电脑方可流畅运行\n\t *\n\t * 如果不启用,则会回退到基于 `transition` 的过渡效果,对低性能的机器比较友好,但是效果会比较单一\n\t */\n\tenableSpring?: boolean;\n\t/**\n\t * 设置是否启用歌词行的模糊效果,默认为 `true`\n\t */\n\tenableBlur?: boolean;\n\t/**\n\t * 设置是否使用物理弹簧算法实现歌词动画效果,默认启用\n\t *\n\t * 如果启用,则会通过弹簧算法实时处理歌词位置,但是需要性能足够强劲的电脑方可流畅运行\n\t *\n\t * 如果不启用,则会回退到基于 `transition` 的过渡效果,对低性能的机器比较友好,但是效果会比较单一\n\t */\n\tenableScale?: boolean;\n\t/**\n\t * 设置是否隐藏已经播放过的歌词行,默认不隐藏\n\t */\n\thidePassedLines?: boolean;\n\t/**\n\t * 设置歌词中不雅用语的掩码模式,默认为 `MaskObsceneWordsMode.Disabled`,即不掩码\n\t */\n\tmaskObsceneWordsMode?: MaskObsceneWordsMode;\n\t/**\n\t * 设置不雅用语掩码使用的字符,默认为 `*`\n\t */\n\tmaskObsceneWordChar?: string;\n\t/**\n\t * 设置当前播放歌词,要注意传入后这个数组内的信息不得修改,否则会发生错误\n\t */\n\tlyricLines?: LyricLine[];\n\t/**\n\t * 设置当前播放进度,单位为毫秒且**必须是整数**,此时将会更新内部的歌词进度信息\n\t * 内部会根据调用间隔和播放进度自动决定如何滚动和显示歌词,所以这个的调用频率越快越准确越好\n\t */\n\tcurrentTime?: number;\n\tisSeeking?: boolean;\n\t/**\n\t * 设置文字动画的渐变宽度,单位以歌词行的主文字字体大小的倍数为单位,默认为 0.5,即一个全角字符的一半宽度\n\t *\n\t * 如果要模拟 Apple Music for Android 的效果,可以设置为 1\n\t *\n\t * 如果要模拟 Apple Music for iPad 的效果,可以设置为 0.5\n\t *\n\t * 如果想要近乎禁用渐变效果,可以设置成非常接近 0 的小数(例如 `0.0001` ),但是**不可以为 0**\n\t */\n\twordFadeWidth?: number;\n\t/**\n\t * 设置所有歌词行在横坐标上的弹簧属性,包括重量、弹力和阻力。\n\t *\n\t * @param params 需要设置的弹簧属性,提供的属性将会覆盖原来的属性,未提供的属性将会保持原样\n\t */\n\tlinePosXSpringParams?: Partial<spring.SpringParams>;\n\t/**\n\t * 设置所有歌词行在纵坐标上的弹簧属性,包括重量、弹力和阻力。\n\t *\n\t * @param params 需要设置的弹簧属性,提供的属性将会覆盖原来的属性,未提供的属性将会保持原样\n\t */\n\tlinePosYSpringParams?: Partial<spring.SpringParams>;\n\t/**\n\t * 设置所有歌词行在缩放大小上的弹簧属性,包括重量、弹力和阻力。\n\t *\n\t * @param params 需要设置的弹簧属性,提供的属性将会覆盖原来的属性,未提供的属性将会保持原样\n\t */\n\tlineScaleSpringParams?: Partial<spring.SpringParams>;\n\t/**\n\t * 在一个特殊的底栏元素内加入指定元素,默认是空白的,可以往内部添加任意元素\n\t *\n\t * 这个元素始终在歌词的底部,可以用于显示歌曲创作者等信息\n\t */\n\tbottomLine?: Parameters<typeof createPortal>[0];\n\t/**\n\t * 需要用于创建歌词播放组件的类实例\n\t */\n\tlyricPlayer?: {\n\t\tnew (\n\t\t\t...args: ConstructorParameters<typeof LyricPlayerBase>\n\t\t): LyricPlayerBase;\n\t};\n\t/**\n\t * 当某个歌词行被左键点击时触发的事件\n\t * @param line 歌词行的事件对象,可以访问到对应的歌词行信息和歌词行索引\n\t */\n\tonLyricLineClick?: (line: LyricLineMouseEvent) => void;\n\t/**\n\t * 当某个歌词行被右键点击时触发的事件\n\t * @param line 歌词行的事件对象,可以访问到对应的歌词行信息和歌词行索引\n\t */\n\tonLyricLineContextMenu?: (line: LyricLineMouseEvent) => void;\n}\n\n/**\n * 歌词播放组件的引用\n */\nexport interface LyricPlayerRef {\n\t/**\n\t * 歌词播放实例\n\t */\n\tlyricPlayer?: LyricPlayerBase;\n\t/**\n\t * 将歌词播放实例的元素包裹起来的 DIV 元素实例\n\t */\n\twrapperEl: HTMLDivElement | null;\n}\n\n/**\n * 歌词播放组件,本框架的核心组件\n *\n * 尽可能贴切 Apple Music for iPad 的歌词效果设计,且做了力所能及的优化措施\n */\nexport const LyricPlayer: ForwardRefExoticComponent<\n\tOmit<HTMLProps<HTMLDivElement> & LyricPlayerProps, \"ref\"> &\n\t\tRefAttributes<LyricPlayerRef>\n> = forwardRef<LyricPlayerRef, HTMLProps<HTMLDivElement> & LyricPlayerProps>(\n\t(\n\t\t{\n\t\t\tdisabled,\n\t\t\tplaying,\n\t\t\talignAnchor,\n\t\t\talignPosition,\n\t\t\tenableSpring,\n\t\t\tenableBlur,\n\t\t\tenableScale,\n\t\t\tmaskObsceneWordsMode,\n\t\t\tmaskObsceneWordChar,\n\t\t\thidePassedLines,\n\t\t\tlyricLines,\n\t\t\tcurrentTime,\n\t\t\tisSeeking,\n\t\t\twordFadeWidth,\n\t\t\tlinePosXSpringParams,\n\t\t\tlinePosYSpringParams,\n\t\t\tlineScaleSpringParams,\n\t\t\tbottomLine,\n\t\t\tlyricPlayer,\n\t\t\tonLyricLineClick,\n\t\t\tonLyricLineContextMenu,\n\t\t\t...props\n\t\t},\n\t\tref,\n\t) => {\n\t\t// const corePlayerRef = useRef<LyricPlayerBase>();\n\t\tconst [corePlayer, setCorePlayer] = useState<LyricPlayerBase>();\n\t\tconst wrapperRef = useRef<HTMLDivElement>(null);\n\t\tconst currentTimeRef = useRef(currentTime);\n\n\t\tuseLayoutEffect(() => {\n\t\t\tconst newPlayer = new (lyricPlayer ?? DefaultLyricPlayer)();\n\t\t\tsetCorePlayer(newPlayer);\n\t\t\twrapperRef.current?.appendChild(newPlayer.getElement());\n\t\t\treturn () => {\n\t\t\t\tnewPlayer?.dispose();\n\t\t\t\tsetCorePlayer(undefined);\n\t\t\t};\n\t\t}, [lyricPlayer]);\n\n\t\tuseLayoutEffect(() => {\n\t\t\tif (lyricLines !== undefined) {\n\t\t\t\tcorePlayer?.setLyricLines(lyricLines, currentTimeRef.current);\n\t\t\t\tcorePlayer?.update();\n\t\t\t} else {\n\t\t\t\tcorePlayer?.setLyricLines([]);\n\t\t\t\tcorePlayer?.update();\n\t\t\t}\n\t\t}, [corePlayer, lyricLines]);\n\n\t\tuseEffect(() => {\n\t\t\tif (!disabled) {\n\t\t\t\tlet canceled = false;\n\t\t\t\tlet lastTime = -1;\n\t\t\t\tconst onFrame = (time: number) => {\n\t\t\t\t\tif (canceled) return;\n\t\t\t\t\tif (lastTime === -1) {\n\t\t\t\t\t\tlastTime = time;\n\t\t\t\t\t}\n\t\t\t\t\tcorePlayer?.update(time - lastTime);\n\t\t\t\t\tlastTime = time;\n\t\t\t\t\trequestAnimationFrame(onFrame);\n\t\t\t\t};\n\t\t\t\tcorePlayer?.calcLayout();\n\t\t\t\trequestAnimationFrame(onFrame);\n\t\t\t\treturn () => {\n\t\t\t\t\tcanceled = true;\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn;\n\t\t}, [corePlayer, disabled]);\n\n\t\tuseEffect(() => {\n\t\t\tif (playing !== undefined) {\n\t\t\t\tif (playing) {\n\t\t\t\t\tcorePlayer?.resume();\n\t\t\t\t} else {\n\t\t\t\t\tcorePlayer?.pause();\n\t\t\t\t}\n\t\t\t} else corePlayer?.resume();\n\t\t}, [corePlayer, playing]);\n\n\t\tuseEffect(() => {\n\t\t\tif (alignAnchor !== undefined) corePlayer?.setAlignAnchor(alignAnchor);\n\t\t}, [corePlayer, alignAnchor]);\n\n\t\tuseEffect(() => {\n\t\t\tif (hidePassedLines !== undefined)\n\t\t\t\tcorePlayer?.setHidePassedLines(hidePassedLines);\n\t\t}, [corePlayer, hidePassedLines]);\n\n\t\tuseEffect(() => {\n\t\t\tif (alignPosition !== undefined)\n\t\t\t\tcorePlayer?.setAlignPosition(alignPosition);\n\t\t}, [corePlayer, alignPosition]);\n\n\t\tuseEffect(() => {\n\t\t\tif (enableSpring !== undefined) corePlayer?.setEnableSpring(enableSpring);\n\t\t\telse corePlayer?.setEnableSpring(true);\n\t\t}, [corePlayer, enableSpring]);\n\n\t\tuseEffect(() => {\n\t\t\tif (enableScale !== undefined) corePlayer?.setEnableScale(enableScale);\n\t\t\telse corePlayer?.setEnableScale(true);\n\t\t}, [corePlayer, enableScale]);\n\n\t\tuseEffect(() => {\n\t\t\tcorePlayer?.setEnableBlur(enableBlur ?? true);\n\t\t}, [corePlayer, enableBlur]);\n\n\t\tuseEffect(() => {\n\t\t\tif (currentTime !== undefined) {\n\t\t\t\tcorePlayer?.setCurrentTime(currentTime, isSeeking);\n\t\t\t\tcurrentTimeRef.current = currentTime;\n\t\t\t} else corePlayer?.setCurrentTime(0);\n\t\t}, [corePlayer, currentTime, isSeeking]);\n\n\t\tuseEffect(() => {\n\t\t\tcorePlayer?.setIsSeeking(!!isSeeking);\n\t\t}, [corePlayer, isSeeking]);\n\n\t\tuseEffect(() => {\n\t\t\tcorePlayer?.setWordFadeWidth(wordFadeWidth);\n\t\t}, [corePlayer, wordFadeWidth]);\n\n\t\tuseEffect(() => {\n\t\t\tif (linePosXSpringParams !== undefined)\n\t\t\t\tcorePlayer?.setLinePosXSpringParams(linePosXSpringParams);\n\t\t}, [corePlayer, linePosXSpringParams]);\n\n\t\tuseEffect(() => {\n\t\t\tif (linePosYSpringParams !== undefined)\n\t\t\t\tcorePlayer?.setLinePosYSpringParams(linePosYSpringParams);\n\t\t}, [corePlayer, linePosYSpringParams]);\n\n\t\tuseEffect(() => {\n\t\t\tif (lineScaleSpringParams !== undefined)\n\t\t\t\tcorePlayer?.setLineScaleSpringParams(lineScaleSpringParams);\n\t\t}, [corePlayer, lineScaleSpringParams]);\n\n\t\tuseEffect(() => {\n\t\t\tif (maskObsceneWordsMode !== undefined) {\n\t\t\t\tcorePlayer?.setMaskObsceneWords(maskObsceneWordsMode);\n\t\t\t} else {\n\t\t\t\tcorePlayer?.setMaskObsceneWords(MaskObsceneWordsMode.Disabled);\n\t\t\t}\n\t\t}, [corePlayer, maskObsceneWordsMode]);\n\n\t\tuseEffect(() => {\n\t\t\tif (maskObsceneWordChar !== undefined) {\n\t\t\t\tcorePlayer?.setMaskObsceneWordChar(maskObsceneWordChar);\n\t\t\t}\n\t\t}, [corePlayer, maskObsceneWordChar]);\n\n\t\tuseEffect(() => {\n\t\t\tif (onLyricLineClick) {\n\t\t\t\tconst handler = (e: Event) =>\n\t\t\t\t\tonLyricLineClick(e as LyricLineMouseEvent);\n\t\t\t\tcorePlayer?.addEventListener(\"line-click\", handler);\n\t\t\t\treturn () => corePlayer?.removeEventListener(\"line-click\", handler);\n\t\t\t}\n\t\t\treturn;\n\t\t}, [corePlayer, onLyricLineClick]);\n\n\t\tuseEffect(() => {\n\t\t\tif (onLyricLineContextMenu) {\n\t\t\t\tconst handler = (e: Event) =>\n\t\t\t\t\tonLyricLineContextMenu(e as LyricLineMouseEvent);\n\t\t\t\tcorePlayer?.addEventListener(\"line-contextmenu\", handler);\n\t\t\t\treturn () =>\n\t\t\t\t\tcorePlayer?.removeEventListener(\"line-contextmenu\", handler);\n\t\t\t}\n\t\t\treturn;\n\t\t}, [corePlayer, onLyricLineContextMenu]);\n\n\t\tuseImperativeHandle(\n\t\t\tref,\n\t\t\t() => ({\n\t\t\t\twrapperEl: wrapperRef.current,\n\t\t\t\tlyricPlayer: corePlayer,\n\t\t\t}),\n\t\t\t[corePlayer],\n\t\t);\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<div {...props} ref={wrapperRef} />\n\t\t\t\t{corePlayer?.getBottomLineElement() && bottomLine\n\t\t\t\t\t? createPortal(bottomLine, corePlayer?.getBottomLineElement())\n\t\t\t\t\t: null}\n\t\t\t</>\n\t\t);\n\t},\n);\n"],"mappings":";;;;;;;;;AAiGA,MAAa,oBAAA,GAAA,MAAA,aAQX,EACC,OACA,cACA,KACA,SACA,WACA,aACA,YACA,eACA,UACA,UACA,OACA,GAAG,SAEJ,QACI;CACJ,MAAM,mBAAA,GAAA,MAAA,QAA+C,KAAK;CAC1D,MAAM,cAAA,GAAA,MAAA,QAAoC,KAAK;CAC/C,MAAM,mBAAA,GAAA,MAAA,QAEH,KAAK;CACR,MAAM,cAAc,YAAYA,6BAAAA;AAEhC,EAAA,GAAA,MAAA,iBAAgB;AACf,MACC,gBAAgB,YAAY,eAC5B,gBAAgB,YAAY,KAAA,GAC3B;AACD,mBAAgB,UAAU;AAC1B,mBAAgB,SAAS,SAAS;AAClC,mBAAgB,UAAUC,6BAAAA,iBAAqB,IAAI,YAAY;;IAE9D,CAAC,YAAY,CAAC;AAEjB,EAAA,GAAA,MAAA,iBAAgB;AACf,MAAI,eAAe,MAClB,iBAAgB,SAAS,SAAS,OAAO,aAAa;IACrD;EAAC;EAAa;EAAO;EAAa,CAAC;AAEtC,EAAA,GAAA,MAAA,iBAAgB;AACf,MAAI,eAAe,IAAK,iBAAgB,SAAS,OAAO,IAAI;IAC1D,CAAC,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,CACC,iBAAA,GAAA,kBAAA,KAAC,OAAD;EAAK,GAAI;EAAO,KAAK;EAAc,CAAA,EAClC,YAAY,sBAAsB,IAAI,cAAA,GAAA,UAAA,cACvB,YAAY,YAAY,sBAAsB,CAAC,GAC5D,KACD,EAAA,CAAA;EAGL"}
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import { AbstractBaseRenderer, BaseRenderer, BaseRenderer as BaseRenderer$1, LyricLine, LyricLineMouseEvent, LyricPlayerBase, MaskObsceneWordsMode, MeshGradientRenderer, PixiRenderer, spring } from "@applemusic-like-lyrics/core";
|
|
2
|
+
import { ForwardRefExoticComponent, HTMLProps, RefAttributes } from "react";
|
|
3
|
+
import { createPortal } from "react-dom";
|
|
4
|
+
|
|
5
|
+
//#region src/bg-render.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* 背景渲染组件的属性
|
|
8
|
+
*/
|
|
9
|
+
interface BackgroundRenderProps {
|
|
10
|
+
/**
|
|
11
|
+
* 设置背景专辑资源
|
|
12
|
+
*/
|
|
13
|
+
album?: string | HTMLImageElement | HTMLVideoElement;
|
|
14
|
+
/**
|
|
15
|
+
* 设置专辑资源是否为视频
|
|
16
|
+
*/
|
|
17
|
+
albumIsVideo?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* 设置当前背景动画帧率,如果为 `undefined` 则默认为 `30`
|
|
20
|
+
*/
|
|
21
|
+
fps?: number;
|
|
22
|
+
/**
|
|
23
|
+
* 设置当前播放状态,如果为 `undefined` 则默认为 `true`
|
|
24
|
+
*/
|
|
25
|
+
playing?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* 设置当前动画流动速度,如果为 `undefined` 则默认为 `2`
|
|
28
|
+
*/
|
|
29
|
+
flowSpeed?: number;
|
|
30
|
+
/**
|
|
31
|
+
* 设置背景是否根据“是否有歌词”这个特征调整自身效果,例如有歌词时会变得更加活跃
|
|
32
|
+
*
|
|
33
|
+
* 部分渲染器会根据这个特征调整自身效果
|
|
34
|
+
*
|
|
35
|
+
* 如果不确定是否需要赋值或无法知晓是否包含歌词,请传入 true 或不做任何处理(默认值为 true)
|
|
36
|
+
*/
|
|
37
|
+
hasLyric?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* 设置低频的音量大小,范围在 80hz-120hz 之间为宜,取值范围在 [0.0-1.0] 之间
|
|
40
|
+
*
|
|
41
|
+
* 部分渲染器会根据音量大小调整背景效果(例如根据鼓点跳动)
|
|
42
|
+
*
|
|
43
|
+
* 如果无法获取到类似的数据,请传入 undefined 或 1.0 作为默认值,或不做任何处理(默认值即 1.0)
|
|
44
|
+
*/
|
|
45
|
+
lowFreqVolume?: number;
|
|
46
|
+
/**
|
|
47
|
+
* 设置当前渲染缩放比例,如果为 `undefined` 则默认为 `0.5`
|
|
48
|
+
*/
|
|
49
|
+
renderScale?: number;
|
|
50
|
+
/**
|
|
51
|
+
* 是否启用静态模式,即图片在更换后就会保持静止状态并禁用更新,以节省性能
|
|
52
|
+
* 默认为 `false`
|
|
53
|
+
*/
|
|
54
|
+
staticMode?: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* 设置渲染器,如果为 `undefined` 则默认为 `PixiRenderer`
|
|
57
|
+
* 默认渲染器有可能会随着版本更新而更换
|
|
58
|
+
*/
|
|
59
|
+
renderer?: {
|
|
60
|
+
new (...args: ConstructorParameters<typeof BaseRenderer$1>): BaseRenderer$1;
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* 背景渲染组件的引用
|
|
65
|
+
*/
|
|
66
|
+
interface BackgroundRenderRef {
|
|
67
|
+
/**
|
|
68
|
+
* 背景渲染实例引用
|
|
69
|
+
*/
|
|
70
|
+
bgRender?: AbstractBaseRenderer;
|
|
71
|
+
/**
|
|
72
|
+
* 将背景渲染实例的元素包裹起来的 DIV 元素实例
|
|
73
|
+
*/
|
|
74
|
+
wrapperEl: HTMLDivElement | null;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* 流体背景渲染组件,通过提供图片链接可以显示出酷似 Apple Music 的流体背景效果
|
|
78
|
+
*/
|
|
79
|
+
declare const BackgroundRender: ForwardRefExoticComponent<Omit<HTMLProps<HTMLDivElement> & BackgroundRenderProps, "ref"> & RefAttributes<BackgroundRenderRef>>;
|
|
80
|
+
//#endregion
|
|
81
|
+
//#region src/lyric-player.d.ts
|
|
82
|
+
/**
|
|
83
|
+
* 歌词播放组件的属性
|
|
84
|
+
*/
|
|
85
|
+
interface LyricPlayerProps {
|
|
86
|
+
/**
|
|
87
|
+
* 是否禁用歌词播放组件,默认为 `false`,歌词组件启用后将会开始逐帧更新歌词的动画效果,并对传入的其他参数变更做出反馈。
|
|
88
|
+
*
|
|
89
|
+
* 如果禁用了歌词组件动画,你也可以通过引用取得原始渲染组件实例,手动逐帧调用其 `update` 函数来更新动画效果。
|
|
90
|
+
*/
|
|
91
|
+
disabled?: boolean;
|
|
92
|
+
/**
|
|
93
|
+
* 是否演出部分效果,目前会控制播放间奏点的动画的播放暂停与否,默认为 `true`
|
|
94
|
+
*/
|
|
95
|
+
playing?: boolean;
|
|
96
|
+
/**
|
|
97
|
+
* 设置歌词行的对齐方式,如果为 `undefined` 则默认为 `center`
|
|
98
|
+
*
|
|
99
|
+
* - 设置成 `top` 的话将会向目标歌词行的顶部对齐
|
|
100
|
+
* - 设置成 `bottom` 的话将会向目标歌词行的底部对齐
|
|
101
|
+
* - 设置成 `center` 的话将会向目标歌词行的垂直中心对齐
|
|
102
|
+
*/
|
|
103
|
+
alignAnchor?: "top" | "bottom" | "center";
|
|
104
|
+
/**
|
|
105
|
+
* 设置默认的歌词行对齐位置,相对于整个歌词播放组件的大小位置,如果为 `undefined`
|
|
106
|
+
* 则默认为 `0.5`
|
|
107
|
+
*
|
|
108
|
+
* 可以设置一个 `[0.0-1.0]` 之间的任意数字,代表组件高度由上到下的比例位置
|
|
109
|
+
*/
|
|
110
|
+
alignPosition?: number;
|
|
111
|
+
/**
|
|
112
|
+
* 设置是否使用物理弹簧算法实现歌词动画效果,默认启用
|
|
113
|
+
*
|
|
114
|
+
* 如果启用,则会通过弹簧算法实时处理歌词位置,但是需要性能足够强劲的电脑方可流畅运行
|
|
115
|
+
*
|
|
116
|
+
* 如果不启用,则会回退到基于 `transition` 的过渡效果,对低性能的机器比较友好,但是效果会比较单一
|
|
117
|
+
*/
|
|
118
|
+
enableSpring?: boolean;
|
|
119
|
+
/**
|
|
120
|
+
* 设置是否启用歌词行的模糊效果,默认为 `true`
|
|
121
|
+
*/
|
|
122
|
+
enableBlur?: boolean;
|
|
123
|
+
/**
|
|
124
|
+
* 设置是否使用物理弹簧算法实现歌词动画效果,默认启用
|
|
125
|
+
*
|
|
126
|
+
* 如果启用,则会通过弹簧算法实时处理歌词位置,但是需要性能足够强劲的电脑方可流畅运行
|
|
127
|
+
*
|
|
128
|
+
* 如果不启用,则会回退到基于 `transition` 的过渡效果,对低性能的机器比较友好,但是效果会比较单一
|
|
129
|
+
*/
|
|
130
|
+
enableScale?: boolean;
|
|
131
|
+
/**
|
|
132
|
+
* 设置是否隐藏已经播放过的歌词行,默认不隐藏
|
|
133
|
+
*/
|
|
134
|
+
hidePassedLines?: boolean;
|
|
135
|
+
/**
|
|
136
|
+
* 设置歌词中不雅用语的掩码模式,默认为 `MaskObsceneWordsMode.Disabled`,即不掩码
|
|
137
|
+
*/
|
|
138
|
+
maskObsceneWordsMode?: MaskObsceneWordsMode;
|
|
139
|
+
/**
|
|
140
|
+
* 设置不雅用语掩码使用的字符,默认为 `*`
|
|
141
|
+
*/
|
|
142
|
+
maskObsceneWordChar?: string;
|
|
143
|
+
/**
|
|
144
|
+
* 设置当前播放歌词,要注意传入后这个数组内的信息不得修改,否则会发生错误
|
|
145
|
+
*/
|
|
146
|
+
lyricLines?: LyricLine[];
|
|
147
|
+
/**
|
|
148
|
+
* 设置当前播放进度,单位为毫秒且**必须是整数**,此时将会更新内部的歌词进度信息
|
|
149
|
+
* 内部会根据调用间隔和播放进度自动决定如何滚动和显示歌词,所以这个的调用频率越快越准确越好
|
|
150
|
+
*/
|
|
151
|
+
currentTime?: number;
|
|
152
|
+
isSeeking?: boolean;
|
|
153
|
+
/**
|
|
154
|
+
* 设置文字动画的渐变宽度,单位以歌词行的主文字字体大小的倍数为单位,默认为 0.5,即一个全角字符的一半宽度
|
|
155
|
+
*
|
|
156
|
+
* 如果要模拟 Apple Music for Android 的效果,可以设置为 1
|
|
157
|
+
*
|
|
158
|
+
* 如果要模拟 Apple Music for iPad 的效果,可以设置为 0.5
|
|
159
|
+
*
|
|
160
|
+
* 如果想要近乎禁用渐变效果,可以设置成非常接近 0 的小数(例如 `0.0001` ),但是**不可以为 0**
|
|
161
|
+
*/
|
|
162
|
+
wordFadeWidth?: number;
|
|
163
|
+
/**
|
|
164
|
+
* 设置所有歌词行在横坐标上的弹簧属性,包括重量、弹力和阻力。
|
|
165
|
+
*
|
|
166
|
+
* @param params 需要设置的弹簧属性,提供的属性将会覆盖原来的属性,未提供的属性将会保持原样
|
|
167
|
+
*/
|
|
168
|
+
linePosXSpringParams?: Partial<spring.SpringParams>;
|
|
169
|
+
/**
|
|
170
|
+
* 设置所有歌词行在纵坐标上的弹簧属性,包括重量、弹力和阻力。
|
|
171
|
+
*
|
|
172
|
+
* @param params 需要设置的弹簧属性,提供的属性将会覆盖原来的属性,未提供的属性将会保持原样
|
|
173
|
+
*/
|
|
174
|
+
linePosYSpringParams?: Partial<spring.SpringParams>;
|
|
175
|
+
/**
|
|
176
|
+
* 设置所有歌词行在缩放大小上的弹簧属性,包括重量、弹力和阻力。
|
|
177
|
+
*
|
|
178
|
+
* @param params 需要设置的弹簧属性,提供的属性将会覆盖原来的属性,未提供的属性将会保持原样
|
|
179
|
+
*/
|
|
180
|
+
lineScaleSpringParams?: Partial<spring.SpringParams>;
|
|
181
|
+
/**
|
|
182
|
+
* 在一个特殊的底栏元素内加入指定元素,默认是空白的,可以往内部添加任意元素
|
|
183
|
+
*
|
|
184
|
+
* 这个元素始终在歌词的底部,可以用于显示歌曲创作者等信息
|
|
185
|
+
*/
|
|
186
|
+
bottomLine?: Parameters<typeof createPortal>[0];
|
|
187
|
+
/**
|
|
188
|
+
* 需要用于创建歌词播放组件的类实例
|
|
189
|
+
*/
|
|
190
|
+
lyricPlayer?: {
|
|
191
|
+
new (...args: ConstructorParameters<typeof LyricPlayerBase>): LyricPlayerBase;
|
|
192
|
+
};
|
|
193
|
+
/**
|
|
194
|
+
* 当某个歌词行被左键点击时触发的事件
|
|
195
|
+
* @param line 歌词行的事件对象,可以访问到对应的歌词行信息和歌词行索引
|
|
196
|
+
*/
|
|
197
|
+
onLyricLineClick?: (line: LyricLineMouseEvent) => void;
|
|
198
|
+
/**
|
|
199
|
+
* 当某个歌词行被右键点击时触发的事件
|
|
200
|
+
* @param line 歌词行的事件对象,可以访问到对应的歌词行信息和歌词行索引
|
|
201
|
+
*/
|
|
202
|
+
onLyricLineContextMenu?: (line: LyricLineMouseEvent) => void;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* 歌词播放组件的引用
|
|
206
|
+
*/
|
|
207
|
+
interface LyricPlayerRef {
|
|
208
|
+
/**
|
|
209
|
+
* 歌词播放实例
|
|
210
|
+
*/
|
|
211
|
+
lyricPlayer?: LyricPlayerBase;
|
|
212
|
+
/**
|
|
213
|
+
* 将歌词播放实例的元素包裹起来的 DIV 元素实例
|
|
214
|
+
*/
|
|
215
|
+
wrapperEl: HTMLDivElement | null;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* 歌词播放组件,本框架的核心组件
|
|
219
|
+
*
|
|
220
|
+
* 尽可能贴切 Apple Music for iPad 的歌词效果设计,且做了力所能及的优化措施
|
|
221
|
+
*/
|
|
222
|
+
declare const LyricPlayer: ForwardRefExoticComponent<Omit<HTMLProps<HTMLDivElement> & LyricPlayerProps, "ref"> & RefAttributes<LyricPlayerRef>>;
|
|
223
|
+
//#endregion
|
|
224
|
+
export { BackgroundRender, BackgroundRenderProps, BackgroundRenderRef, BaseRenderer, LyricPlayer, LyricPlayerProps, LyricPlayerRef, MeshGradientRenderer, PixiRenderer };
|
|
225
|
+
//# sourceMappingURL=amll-react.d.cts.map
|