Skip to content

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

MethodSignatureNotes
videoElementreadonly HTMLVideoElement | undefinedThe raw element. undefined until the first backend() call.
backend()() => IVideoBackendThe 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 | nullThe displayed content rectangle under object-fit: contain, null before metadata loads. Changes fire 'videoRect'.

Fullscreen, PiP, theater

MethodSignatureNotes
fullscreen() / fullscreen(state)() => FullscreenState, (state: FullscreenState | boolean) => voidThrows core:policy/fullscreenUnsupported with no platform fullscreen controller configured.
pip() / pip(state)() => PipState, (state: PipState | boolean) => voidThrows core:policy/pipUnsupported with no platform PiP controller.
theater() / theater(state)() => TheaterState, (state: TheaterState | boolean) => voidPure UI-layout state, no browser API behind it.
subtitleState()() => SubtitleStateWhether any subtitle track is active, checks subtitle() first, falls back to scanning native textTracks.
toggleFullscreen() / togglePip() / toggleTheater()() => voidFlip the matching state.

Aspect ratio

MethodSignatureNotes
aspectRatio() / aspectRatio(value)() => Stretching, (value: Stretching) => void'uniform' (contain, default) / 'fill' / 'exactfit' (cover) / 'none'.
cycleAspectRatio()() => voidSteps through ['uniform', 'fill', 'exactfit', 'none'] in order.

Track selection

MethodSignatureNotes
subtitles()() => SubtitleTrack[]Track list for the active item.
subtitle() / subtitle(idx)() => CurrentSubtitleSelection | null, (idx: number | null) => Promise<void>null selects off.
cycleSubtitles()() => voidWalks off -> 0 -> ... -> N-1 -> off.
subtitleStyle() / subtitleStyle(patch)() => SubtitleStyle, (patch: Partial<SubtitleStyle>) => voidIn-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()() => voidWraps around the list.
qualityLevels() / qualityLevels({ includeUnsupported: true })() => QualityLevel[]Populated once 'levels' fires.
quality() / quality(idx)() => CurrentQualitySelection | 'auto', (idx: number | 'auto') => voidSetting 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

MethodSignatureNotes
playSegment(opts)(opts: SegmentOptions) => voidSeeks to startSec, watches for endSec, applies onEnd ('loop' / 'hold' / 'advance'). Always emits 'segmentBoundary' at the boundary. Replaces any previously active window immediately.
clearSegment()() => voidStops 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