index ↓
lyrics
client.lyrics requests
you ask, the daemon answers. await the tagged result and check .ok
get(): Promise<TypedRequestResult<LyricsReply, LyricsErrorReply>>
push form: onLyricsReply (subscribe instead of awaiting)
Webapp asks for lyrics of whatever is playing right now. Deliberately payload-free: the daemon builds the track identity from its own player state, so a webapp cannot disagree with it about what is playing.
const res = await client.lyrics.get();
if (res.ok) {
console.log(res.response.lyrics);
} else {
console.warn(res.kind, res.error);
} type Result =
| { ok: true; response: LyricsReply }
| { ok: false; kind: 'domain'; error: LyricsErrorReply }
| { ok: false; kind: 'protocol'; error: WireError }; types
shapes referenced above, as the sdk types them
type LyricsReply = {
lyrics?: Lyrics;
}; type LyricsErrorReply = {
message: string;
}; Lyrics for one track. synced and plain are independent: a source may carry either, both,
or neither. source names the provider so a webapp can attribute it.
type Lyrics = {
synced?: LyricLine[];
plain?: string;
source: string;
}; One timed line. start_ms is relative to track start, so a webapp highlights against the
same clock it draws the progress bar from.
type LyricLine = {
startMs: number;
text: string;
};