Reference: Video Player Methods
NMVideoPlayer<T> implements IVideoPlayer<T>, which extends the kit’s IPlayer<VideoEventMap<T>>. Everything on IPlayer (play(), pause(), time(), volume(), queue(), addPlugin(), and the rest of transport, queue, volume, and plugin management) is unchanged kit surface, documented method by method across the Guided Tour rather than duplicated here. This page is the delta: everything that exists only because the medium is video.
Video element & geometry
| Method | Signature | Notes |
|---|---|---|
videoElement | readonly HTMLVideoElement | undefined | The raw element. undefined until the first backend() call. |
backend() | () => IVideoBackend | The active backend instance, constructed lazily on first call. See Adapter: Video Backend. |
backend(kind) | (kind: VideoBackendKind) => Promise<void> | Swaps the active backend at runtime, disposing the current instance and emitting 'backend:changed'. Only 'html5' has a built-in implementation, 'mse' and 'webcodecs' need options.backendFactory to supply one, otherwise the swap rejects with core:not-implemented/video-backend. |
videoRect() | () => VideoRect | null | The displayed content rectangle under object-fit: contain, null before metadata loads. Changes fire 'videoRect'. |
Fullscreen, PiP, theater
| Method | Signature | Notes |
|---|---|---|
fullscreen() / fullscreen(state) | () => FullscreenState, (state: FullscreenState | boolean) => void | Throws core:policy/fullscreenUnsupported with no platform fullscreen controller configured. |
pip() / pip(state) | () => PipState, (state: PipState | boolean) => void | Throws core:policy/pipUnsupported with no platform PiP controller. |
theater() / theater(state) | () => TheaterState, (state: TheaterState | boolean) => void | Pure UI-layout state, no browser API behind it. |
subtitleState() | () => SubtitleState | Whether any subtitle track is active, checks subtitle() first, falls back to scanning native textTracks. |
toggleFullscreen() / togglePip() / toggleTheater() | () => void | Flip the matching state. |
Aspect ratio
| Method | Signature | Notes |
|---|---|---|
aspectRatio() / aspectRatio(value) | () => Stretching, (value: Stretching) => void | 'uniform' (contain, default) / 'fill' / 'exactfit' (cover) / 'none'. |
cycleAspectRatio() | () => void | Steps through ['uniform', 'fill', 'exactfit', 'none'] in order. |
Track selection
| Method | Signature | Notes |
|---|---|---|
subtitles() | () => SubtitleTrack[] | Track list for the active item. |
subtitle() / subtitle(idx) | () => CurrentSubtitleSelection | null, (idx: number | null) => Promise<void> | null selects off. |
cycleSubtitles() | () => void | Walks off -> 0 -> ... -> N-1 -> off. |
subtitleStyle() / subtitleStyle(patch) | () => SubtitleStyle, (patch: Partial<SubtitleStyle>) => void | In-memory only, persistence is a consumer concern, see Adapter: Subtitle Style Store. |
audioTracks() | () => AudioTrack[] | Embedded audio rendition list. |
audioTrack() / audioTrack(idx) | () => CurrentAudioTrackSelection | null, (idx: number) => Promise<void> | |
cycleAudioTracks() | () => void | Wraps around the list. |
qualityLevels() / qualityLevels({ includeUnsupported: true }) | () => QualityLevel[] | Populated once 'levels' fires. |
quality() / quality(idx) | () => CurrentQualitySelection | 'auto', (idx: number | 'auto') => void | Setting a level also emits 'quality:requested' immediately, before 'level-switched' confirms. |
chapters(), chapter() / chapter(idx), seekToChapter(idx, opts?), nextChapter(opts?), and previousChapter(opts?) are shared IPlayer surface, not a video addition, nomercy-music-player has the same chapter methods for podcast-style chapter markers. They’re covered on the Guided Tour: Chapters rather than repeated here.
Segment / window playback
| Method | Signature | Notes |
|---|---|---|
playSegment(opts) | (opts: SegmentOptions) => void | Seeks to startSec, watches for endSec, applies onEnd ('loop' / 'hold' / 'advance'). Always emits 'segmentBoundary' at the boundary. Replaces any previously active window immediately. |
clearSegment() | () => void | Stops watching without seeking or pausing. No-op with nothing active. |
Generic enough for intro loops, chapter-range playback, or a disc-menu’s skipToMark equivalent, none of which are disc-specific in the primitive itself.
Playback re-declarations
IVideoPlayer re-declares a handful of methods that already belong to the shared player surface, so they read next to the video-specific methods for doc locality rather than adding anything new: time(), duration(), playbackRate(), togglePlayback(), toggleMute(), rewind(), forward(), playState(), volumeState(), volume(), buffered(), play(), pause(), stop(), next(), previous(), item(), queueLength(), index(), queue(), playbackRates(). They are already required on IPlayer (with item() supplied by the shared WithCurrentItem capability), so the re-declarations are redundant; the item-bearing ones re-type their playlist values with the concrete video item type T. Signatures and behavior are unchanged from IPlayer, see the Guided Tour.
Coming from v1
Method names that were removed or renamed in v2 are not part of the IVideoPlayer surface above. To move a v1 app across without rewriting every call at once, see Migrating from v1.
Next steps
- Reference: VideoPlayerConfig: the
setup(config)fields specific to video, on top of the kit’s shared config. - Reference: Metrics, Clock & Accessibility:
metrics(),now(),announce(), and thebandwidth()/canPlay()pair Quality Levels already walks through in a video context, shared kit surface not re-declared onIVideoPlayer.