Writing Plugins
Plugin catalog
All plugins importable from @nomercy-entertainment/nomercy-music-player/plugins:
| Plugin | id | What it does |
|---|---|---|
AutoAdvancePlugin | auto-advance | Advances the queue on ended; optionally preloads and crossfades on trackEndingSoon. |
LyricsPlugin | lyrics | Fetches and time-syncs lyrics via the cue parser registry; fires line / lineEnter / lineExit. |
CastSenderPlugin | cast-sender | Chromecast sender, music-specific metadata + audio/mpeg content type; full session lifecycle from the core. |
MediaSessionPlugin | media-session | Publishes track metadata and artwork to the OS Media Session API (lock screen, notification panel). |
MusicUiPlugin | music-ui | Self-contained HTML transport overlay: album art, track info, seek bar, controls, volume. |
KeyHandlerPlugin | key-handler | Keyboard shortcuts: space, arrows, m (core) + n, p, r, s (music-specific). |
TabLeaderPlugin | tab-leader | Web Locks single-tab-active enforcer, only one tab plays at a time. |
MessagePlugin | message | Toast and persistent overlay surface: show(), queue(), displayPersistent(). |
EmbedPlugin | embed | postMessage bridge for host-page ↔ iframe player communication. |
AudioGraphPlugin | audio-graph | Web Audio AudioContext owner, prerequisite for all graph plugins. (from core) |
EqualizerPlugin | equalizer | 10-band parametric EQ with pre-gain, built-in presets, and persistence. (from core) |
SpectrumPlugin | spectrum | Frequency-domain visualiser data via the shared AnalyserNode. (from core) |
MixerPlugin | mixer | Per-channel gain and panning. (from core) |
CanvasPlugin | canvas | <canvas> RAF renderer, plug in a custom CanvasRenderFn for visualisations. (from core) |
GroupListeningPlugin | group-listening | Synchronised multi-client listening. Roadmapped v2.1, throws NotImplementedError. |
DrmPlugin | music-drm | EME (Widevine / FairPlay / PlayReady). Roadmapped v2.1, throws NotImplementedError. |
LiveTranscodingPlugin | live-transcoding | Server-coordinated live transcoding with backpressure. Roadmapped v2.1, throws NotImplementedError. |
Music plugins extend the core’s Plugin base class with NMMusicPlayer<any> as the player type.
This gives you typed access to all music-specific methods (backend(), crossfadeTo(), isTransitioning()) through this.player.
For the full plugin authoring guide including lifecycle, helpers, i18n, and the plugin contract, see Writing Plugins in the player core docs.
Quick example
TypeScript
import { Plugin } from '@nomercy-entertainment/nomercy-player-core';
import type { NMMusicPlayer } from '@nomercy-entertainment/nomercy-music-player';
interface NowPlayingOptions {
endpoint: string;
}
export class NowPlayingPlugin extends Plugin<NMMusicPlayer<any>, NowPlayingOptions> {
static override readonly id = 'now-playing';
static override readonly version = '1.0.0';
override use(): void {
this.on('current', ({ item }) => {
if (item) {
void this.fetch(this.opts!.endpoint, {
method: 'POST',
body: JSON.stringify({
name: item.name,
artist: item.artist,
}),
});
}
});
}
}
Registration:
TypeScript
player.addPlugin(NowPlayingPlugin, { endpoint: 'https://api.example.com/now-playing' });
Key differences from video plugins
this.playeris typed asNMMusicPlayer<any>, notNMVideoPlayer- Available music events:
current,trackEndingSoon,crossfadeStart,crossfadeComplete,repeat,shuffle,backend:changed - Music methods available:
this.player.backend(),this.player.crossfadeTo(),this.player.isTransitioning() - Audio backend access:
this.player.backend().outputNode(ctx)for graph plugins
See also
- Advanced: Custom Plugin (Music), full example with backend access and custom events
- Player Core, Writing Plugins, complete plugin lifecycle reference