- TypeScript 99.3%
- JavaScript 0.7%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| .github/workflows | ||
| scripts | ||
| src | ||
| .gitattributes | ||
| .gitignore | ||
| CHANGELOG.md | ||
| CLAUDE.md | ||
| CODE_OF_CONDUCT.md | ||
| CONTRIBUTING.md | ||
| eslint.config.js | ||
| LICENSE | ||
| MIGRATION.md | ||
| package-lock.json | ||
| package.json | ||
| README.md | ||
| RELEASING.md | ||
| SECURITY.md | ||
| TESTING.md | ||
| tsconfig.build.json | ||
| tsconfig.json | ||
| vitest.config.ts | ||
Full documentation: https://docs.nomercy.tv/nomercy-player-core/
nomercy-player-core
The shared, headless engine that the video and music players are built on.
It carries everything that is not specific to video or audio: the queue, auth, the plugin system, the typed event bus, i18n, and storage.
You stay in charge.
Nothing renders a UI on its own. Nothing is forced on you.
- Everything is opt-in. No plugin runs until you
addPluginit. The engine ships quiet, you add only what you want. - Swap any behavior through adapters. The clock, fetch, storage, logger, retry policy, shuffle, URL resolver, stream registry, and more are each an interface with a default. Pass your own to
setup(). No subclassing. - Plain events and methods. The engine reports through a typed event bus. How you react, and what you build, is yours.
You rarely install this package directly.
Pull in nomercy-video-player or nomercy-music-player and the core comes with it.
Install it on its own only when you are writing a plugin or building a new player package on the core.
npm install @nomercy-entertainment/nomercy-player-core
Quick start
The core is the player engine. Compose its method mixins onto a class and you have a working player: the queue, transport, loading pipeline, time and volume, the typed event bus, auth, and the plugin system are all there. A library on top of the core adds only the medium-specific piece, the backend that turns a source into sound or picture.
import {
composeMixins,
initPlayerCoreState,
lifecycleMethods,
playerCoreMethods,
queueMethods,
timeMethods,
transportMethods,
volumeMethods,
} from '@nomercy-entertainment/nomercy-player-core';
class MyPlayer {
constructor(id: string) {
initPlayerCoreState(this, { className: 'MyPlayer' });
this.setup({ playlist: [{ id, url: '...' }] });
}
}
composeMixins(
MyPlayer.prototype,
playerCoreMethods,
lifecycleMethods,
queueMethods,
transportMethods,
timeMethods,
volumeMethods,
);
const player = new MyPlayer('intro');
player.on('ready', () => player.play());
player.queue();
player.time(30);
That player drives the full core surface. The only thing it does not do on its own is render a medium, which is what nomercy-video-player and nomercy-music-player add. Reach for the core directly when you are building a new player package like those, not when you just want to play video or audio.
Two extension points put you in control of the rest. Adapters replace any cross-cutting concern through setup(), no subclassing. Override only what you want; everything else keeps its default:
import { LocalStorageBackend } from '@nomercy-entertainment/nomercy-player-core';
player.setup({
storage: new LocalStorageBackend(), // or your own IStorage
logger: myLogger, // your own ILogger
shuffleStrategy: myShuffle, // your own IShuffleStrategy
urlResolver: mySignedUrls, // your own IUrlResolver
});
Plugins are opt-in and ride the same typed event bus. Nothing registers itself; you add what you want. A plugin reads through this.on, emits its own events, and needs no manual teardown, the base disposes every this.on subscription and mounted element for it:
import { Plugin } from '@nomercy-entertainment/nomercy-player-core';
export class PlayCountPlugin extends Plugin {
static override readonly id = 'play-count';
override use(): void {
this.on('play', () => this.emit('play-count:changed', undefined));
}
}
player.addPlugin(PlayCountPlugin);
Documentation
The docs site is the full reference, ordered from first player to plugin author:
- Introduction and Quick Start, composing the core into a player
- The Guided Tour over the lifecycle, the event bus, the adapter ports, and the plugin base
- Build a Player and Recipe: use authFetch
- The full type reference and Testing your plugins with the
describePluginconformance helper the kit ships
License
Apache-2.0
Repository: github.com/NoMercy-Entertainment/nomercy-player-core