@uimaxbai/am-lyrics 1.0.5 → 1.0.7
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 +24 -24
- package/demo/index.html +2 -2
- package/dist/src/AmLyrics.d.ts +5 -2
- package/dist/src/AmLyrics.d.ts.map +1 -1
- package/dist/src/am-lyrics.js +317 -209
- package/dist/src/am-lyrics.js.map +1 -1
- package/dist/src/react.js +317 -209
- package/dist/src/react.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/AmLyrics.ts +347 -211
package/README.md
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
This webcomponent follows the [open-wc](https://github.com/open-wc/open-wc) recommendation.
|
|
6
6
|
|
|
7
|
+
This web component utilises the [lyricsplus](https://github.com/ibratabian17/YouLyPlus) API to fetch lyrics and the animations are heavily inspired by [YouLy+](https://github.com/ibratabian17/YouLyPlus).
|
|
8
|
+
|
|
7
9
|
## Installation
|
|
8
10
|
|
|
9
11
|
```bash
|
|
@@ -37,23 +39,23 @@ Or, just use the CDN.
|
|
|
37
39
|
|
|
38
40
|
## Properties & Attributes
|
|
39
41
|
|
|
40
|
-
| Property/Attribute
|
|
41
|
-
|
|
42
|
-
| `query`
|
|
43
|
-
| `music-id`
|
|
44
|
-
| `isrc`
|
|
45
|
-
| `song-title`
|
|
46
|
-
| `song-artist`
|
|
47
|
-
| `song-album`
|
|
48
|
-
| `song-duration`
|
|
49
|
-
| `current-time`
|
|
50
|
-
| `duration`
|
|
51
|
-
| `highlight-color`
|
|
52
|
-
| `hover-background-color` | `string`
|
|
53
|
-
| ~~`hide-source-footer`~~ | `boolean` | `false`
|
|
54
|
-
| `font-family`
|
|
55
|
-
| `autoscroll`
|
|
56
|
-
| `interpolate`
|
|
42
|
+
| Property/Attribute | Type | Default | Description |
|
|
43
|
+
| ------------------------ | --------- | ----------- | ---------------------------------------------------------------------------------------------- |
|
|
44
|
+
| `query` | `string` | `undefined` | Search phrase that resolves metadata via LyricsPlus catalog (falls back to Apple Music search) |
|
|
45
|
+
| `music-id` | `string` | `undefined` | Specific Apple Music song ID (served through the backup Apple endpoint) |
|
|
46
|
+
| `isrc` | `string` | `undefined` | ISRC code to verify correct song match |
|
|
47
|
+
| `song-title` | `string` | `undefined` | Preferred title for LyricsPlus (primary) provider |
|
|
48
|
+
| `song-artist` | `string` | `undefined` | Preferred artist name for LyricsPlus provider |
|
|
49
|
+
| `song-album` | `string` | `undefined` | Optional album name passed to LyricsPlus provider |
|
|
50
|
+
| `song-duration` | `number` | `undefined` | Optional song duration in milliseconds sent to LyricsPlus |
|
|
51
|
+
| `current-time` | `number` | `0` | Current playback time in milliseconds |
|
|
52
|
+
| `duration` | `number` | `undefined` | Playback timer duration in milliseconds. **Set to `-1` to reset/stop playback** |
|
|
53
|
+
| `highlight-color` | `string` | `"#000"` | Color for highlighted/active lyrics |
|
|
54
|
+
| `hover-background-color` | `string` | `"#f0f0f0"` | Background color on line hover |
|
|
55
|
+
| ~~`hide-source-footer`~~ | `boolean` | `false` | Hide/show the source attribution footer |
|
|
56
|
+
| `font-family` | `string` | `undefined` | Custom font family for lyrics |
|
|
57
|
+
| `autoscroll` | `boolean` | `true` | Enable automatic scrolling to active lyrics |
|
|
58
|
+
| `interpolate` | `boolean` | `true` | Enable smooth word-by-word highlighting animation |
|
|
57
59
|
|
|
58
60
|
## CSS Custom Properties (CSS Variables)
|
|
59
61
|
|
|
@@ -63,10 +65,10 @@ You can customize the appearance using CSS custom properties:
|
|
|
63
65
|
am-lyrics {
|
|
64
66
|
/* Highlight color for active lyrics */
|
|
65
67
|
--am-lyrics-highlight-color: #007aff;
|
|
66
|
-
|
|
68
|
+
|
|
67
69
|
/* Hover background color (fallback) */
|
|
68
70
|
--hover-background-color: #f5f5f5;
|
|
69
|
-
|
|
71
|
+
|
|
70
72
|
/* Alternative highlight color (fallback) */
|
|
71
73
|
--highlight-color: #000;
|
|
72
74
|
}
|
|
@@ -74,7 +76,6 @@ am-lyrics {
|
|
|
74
76
|
|
|
75
77
|
**Note**: The CSS variables take precedent over the set properties above.
|
|
76
78
|
|
|
77
|
-
|
|
78
79
|
## Lyrics providers
|
|
79
80
|
|
|
80
81
|
The component now only uses the LyricsPlus (KPoe) API that powers [YouLyPlus](https://github.com/ibratabian17/YouLyPlus).
|
|
@@ -82,8 +83,7 @@ The component now only uses the LyricsPlus (KPoe) API that powers [YouLyPlus](ht
|
|
|
82
83
|
1. Provide `song-title` and `song-artist` (plus optional `song-album`/`song-duration`) to request word-synced lyrics from LyricsPlus. A standalone `query` such as `"Bad Habit - Steve Lacy"` also works—the component looks up the metadata through LyricsPlus' `/v1/songlist/search` endpoint.
|
|
83
84
|
2. If LyricsPlus cannot serve lyrics or metadata is missing, the component automatically falls back to the legacy Apple Music endpoint using the best available identifiers (`query`, `music-id`, `isrc`). Requests that rely solely on `music-id` are handled exclusively by this backup service because LyricsPlus does not support Apple IDs.
|
|
84
85
|
|
|
85
|
-
The footer shows the active provider (e.g. “LyricsPlus (KPoe)” or “Apple Music”) so you always know which service responded. Supplying both metadata
|
|
86
|
-
|
|
86
|
+
The footer shows the active provider (e.g. “LyricsPlus (KPoe)” or “Apple Music”) so you always know which service responded. Supplying both metadata _and_ a `query` gives the best results because the query remains available for the Apple Music backup.
|
|
87
87
|
|
|
88
88
|
## Events
|
|
89
89
|
|
|
@@ -92,7 +92,7 @@ The footer shows the active provider (e.g. “LyricsPlus (KPoe)” or “Apple M
|
|
|
92
92
|
Fired when a user clicks on a lyrics line.
|
|
93
93
|
|
|
94
94
|
```javascript
|
|
95
|
-
amLyrics.addEventListener('line-click',
|
|
95
|
+
amLyrics.addEventListener('line-click', event => {
|
|
96
96
|
console.log('Seek to:', event.detail.timestamp); // timestamp in milliseconds
|
|
97
97
|
});
|
|
98
98
|
```
|
|
@@ -295,7 +295,7 @@ You can synchronize the lyrics with an HTML `<audio>` element.
|
|
|
295
295
|
});
|
|
296
296
|
|
|
297
297
|
// Seek audio when a lyric line is clicked
|
|
298
|
-
amLyrics.addEventListener('line-click',
|
|
298
|
+
amLyrics.addEventListener('line-click', e => {
|
|
299
299
|
// The event detail contains the timestamp in milliseconds
|
|
300
300
|
audioPlayer.currentTime = e.detail.timestamp / 1000;
|
|
301
301
|
audioPlayer.play();
|
package/demo/index.html
CHANGED
package/dist/src/AmLyrics.d.ts
CHANGED
|
@@ -51,7 +51,6 @@ export declare class AmLyrics extends LitElement {
|
|
|
51
51
|
private animatingLines;
|
|
52
52
|
private scrollUnlockTimeout?;
|
|
53
53
|
private scrollAnimationTimeout?;
|
|
54
|
-
private consecutiveOverlapCount;
|
|
55
54
|
private lastActiveIndex;
|
|
56
55
|
private visibleLineIds;
|
|
57
56
|
connectedCallback(): void;
|
|
@@ -74,6 +73,11 @@ export declare class AmLyrics extends LitElement {
|
|
|
74
73
|
*/
|
|
75
74
|
private _onTimeChanged;
|
|
76
75
|
updated(changedProperties: Map<string | number | symbol, unknown>): void;
|
|
76
|
+
/**
|
|
77
|
+
* Handle scrolling when active line indices change.
|
|
78
|
+
* Called imperatively from _onTimeChanged instead of from updated().
|
|
79
|
+
*/
|
|
80
|
+
private _handleActiveLineScroll;
|
|
77
81
|
private _textWidthCanvas;
|
|
78
82
|
private _textWidthCtx;
|
|
79
83
|
private _getTextWidth;
|
|
@@ -100,7 +104,6 @@ export declare class AmLyrics extends LitElement {
|
|
|
100
104
|
private getScrollPaddingTop;
|
|
101
105
|
/**
|
|
102
106
|
* Animate scroll with staggered delay for smooth YouLyPlus-style scrolling
|
|
103
|
-
* (Exact copy from YouLyPlus _animateScroll)
|
|
104
107
|
*/
|
|
105
108
|
private animateScrollYouLy;
|
|
106
109
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AmLyrics.d.ts","sourceRoot":"","sources":["../../src/AmLyrics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,UAAU,EAAE,MAAM,KAAK,CAAC;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