Skip to content

Exported types

All types are importable from the package root:

TypeScript
import type {
VideoPlaylistItem,
VideoPlayerConfig,
VideoEventMap,
IVideoPlayer,
VideoBackendFactory,
Stretching,
WatchProgress,
FontTrackRef,
SubtitleTrackRef,
AudioTrackRef,
ChapterRef,
SkipperData,
SkipperRange,
} from '@nomercy-entertainment/nomercy-video-player';

IVideoPlayer

TypeScript
interface IVideoPlayer<T extends BasePlaylistItem = VideoPlaylistItem>
extends IPlayer<VideoEventMap>

Typed contract for the video player’s public surface. Use this to type plugin parameters and consumer functions rather than the concrete NMVideoPlayer class. The interface is stable across patch versions.

TypeScript
import type { IVideoPlayer } from '@nomercy-entertainment/nomercy-video-player';
import { Plugin } from '@nomercy-entertainment/nomercy-player-core';

class MyPlugin extends Plugin<IVideoPlayer> {
override use(): void {
this.on('ready', () => {
this.player.play();
});
}
}

VideoPlaylistItem

See VideoPlaylistItem for full field documentation.

VideoPlayerConfig

Configuration passed to player.setup(config).

FieldTypeDefaultDescription
playlistVideoPlaylistItem[] | stringnoneInitial playlist or URL to fetch
mutedbooleanfalseStart muted
autoPlaybooleanfalseAuto-play on setup
controlsbooleanfalseShow the native <video> controls element
stretching'uniform' | 'fill' | 'exactfit' | 'none''uniform'Aspect ratio stretching mode
playbackRatesnumber[][0.5, 0.75, 1, 1.25, 1.5, 2] (fixed)Intended rate list; not yet read by the player (the list is currently fixed)
preload'auto' | 'metadata' | 'none'browser defaultIntended <video> preload attribute; not yet read by the player
disableMediaControlsbooleanfalseDisable media key bindings (keyboard plugin)
disableControlsbooleanfalseDisable all controls
backendFactoryVideoBackendFactorynoneCustom backend factory (advanced)
defaultSubtitleLanguagestringnoneBCP-47 language tag to auto-select on load
defaultAudioLanguagestringnoneBCP-47 language tag to auto-select on load
defaultQuality'auto' | number'auto'Default quality level index or 'auto'
theaterDefaultbooleanfalseStart in theater mode
baseImageUrlstringnoneBase URL prepended to relative image paths on playlist items

State enums

All state enums are exported from the package root:

PlayState

Returned by player.playState().

ValueDescription
'idle'No media loaded
'loading'Media is loading or buffering
'playing'Media is actively playing
'paused'Media is paused
'stopped'Playback stopped explicitly
'error'A fatal error occurred

FullscreenState

ValueDescription
'off'Not in fullscreen
'on'In fullscreen

PipState

ValueDescription
'off'Picture-in-Picture is inactive
'on'Picture-in-Picture is active

TheaterState

ValueDescription
'off'Normal layout
'on'Theater (wide) mode active

SubtitleState

ValueDescription
'off'No subtitle track active
'on'A subtitle track is active

VolumeState

ValueDescription
'unmuted'Audio is playing
'muted'Audio is muted

RepeatState

ValueDescription
'off'No repeat
'all'Repeat entire playlist
'one'Repeat current item

ShuffleState

ValueDescription
'off'Sequential playback
'on'Shuffled playback

Stretching

TypeScript
type Stretching = 'uniform' | 'fill' | 'exactfit' | 'none';

Controls how the video is scaled to fill the player container. Used by aspectRatio() and cycleAspectRatio(). See Aspect Ratio.

VideoBackendFactory

TypeScript
type VideoBackendFactory = (
kind: VideoBackendKind,
config: VideoPlayerConfig<BasePlaylistItem>,
) => IVideoBackend;

Custom backend factory passed in VideoPlayerConfig.backendFactory. Receives the resolved backend kind and the player config. See Video Backend adapter.

VideoEventMap

The full map of events emitted by NMVideoPlayer. Subscribe with player.on(event, listener).

EventPayloadDescription
'current'{ item: VideoPlaylistItem | undefined; index: number }Active playlist item changed
'quality:requested'{ level: number | 'auto' }Quality level requested by consumer
'chapter'{ index: number; title: string }Emitted by seekToChapter / nextChapter / previousChapter (not on boundary crossing)
'pip'{ active: boolean }PiP state changed
'theater'{ active: boolean }Theater mode changed
'fullscreen'{ active: boolean }Fullscreen state changed
'mute'{ muted: boolean }Mute state changed
'volume'{ level: number }Volume level changed (0–100)
'repeat'{ state: RepeatState }Repeat mode changed
'shuffle'{ state: ShuffleState }Shuffle mode changed
'aspectRatio'{ value: Stretching }Aspect ratio changed
'waiting'voidVideo element is buffering
'canplay'voidEnough data to begin playback
'stalled'voidNetwork stalled
'levels'{ levels: QualityLevel[] }HLS quality levels available
'level-switched'{ level: number }ABR switched quality level
'audioTracks'{ tracks: AudioTrack[] }Audio track list available
'back'voidBack button in the desktop UI was pressed

Player Core base events (ready, time, duration, play, pause, ended, error, subtitle, subtitleCue, subtitleStyle, mediaReady, etc.) are inherited from BaseEventMap and documented at /nomercy-player-core/event-system.

See also