extend library

扩展入口:会话、无缝切换、预览、平台端口及上报等高级接缝。 下方单独公告的内部 helper 仅为兼容保留,计划下个版本从公开入口隐藏; 宿主应优先实现端口或使用 createMova。其余扩展契约继续保留。

Classes

IMovaBrightness
A port for reading and writing the device/app screen brightness.
IMovaBrightnessRestore
亮度端口的可选还原能力,用于恢复应用覆盖或交还系统亮度控制。
IMovaCutover
The cutover capability surface consumers drive, kept separate from IMovaApi so callers like MovaAds depend on the cutover verbs alone and can be tested against a tiny fake.
IMovaErrorPolicy
Decides whether a playback error is fatal and what stable code it carries.
IMovaFramePuller
Decodes one frame of a media at a given position, downscaled for preview.
IMovaHeaderedFramePuller
可选的带头抽帧能力;不改变旧抽帧端口的签名。
IMovaHeaderedHttpFetch
可选的带头 HTTP 能力;旧 IMovaHttpFetch.get 签名保持不变。
IMovaHttpFetch
Fetches small auxiliary assets (WebVTT tracks, sprite sheets) over HTTP.
IMovaKeepAlive
Players that can keep a stream warm while their picture is hidden. A capability next to IMovaApi (like IMovaCutover); check with is.
IMovaNetProbe
Reports whether the current connection is suitable for bandwidth-heavy, non-essential traffic such as sprite sheets and frame extraction.
IMovaOrient
A port for applying and resetting fullscreen/immersive orientation and system UI state.
IMovaPip
A port for entering system picture-in-picture mode.
IMovaPipObservable
Optional capability of a IMovaPip: reports PiP mode changes that happen outside IMovaPip.enter (the user closes or expands the PiP window). The player probes it with is, so existing ports stay valid.
IMovaRecoveryPolicy
Decides how to recover from a playback failure. The playback-side twin of IMovaAdFailPolicy: pure and injectable, so hosts with their own retry budgets replace it wholesale.
IMovaReporter
Unified reporting sink: hosts implement this to receive every report event mova produces.
IMovaStallPolicy
Turns a stream of "stalled right now" observations into completed stall records. Mirrors IMovaAbrPolicy: mova ships a default, hosts can inject.
IMovaStatsProbe
Optional kernel capability exposing libmpv's own statistics. A kernel that does not implement it simply degrades the QoE layer — never an error.
IMovaThumbCache
Storage for encoded thumbnail bytes, keyed by a cache key.
IMovaThumbDirProvider
Resolves the on-disk directory thumbnails are cached in.
IMovaThumbSource
One strategy for obtaining a preview thumbnail at a given position.
IMovaVolume
A port for reading and writing the device's system media volume, as a percentage in [0, 100].
IMovaWarmPolicy
Decides when a warming shadow player is ready to become the live one.
IMovaWarmTrigger
Decides whether warming should start now for a given MovaWarmCue.
MovaAlwaysAllowNetProbe
A IMovaNetProbe that always permits heavy traffic.
MovaAutoPause
Pauses api while child is hidden — scrolled out of its viewport, in an inactive tab/Offstage, covered by another route, or with the app in the background — and resumes it afterwards if it was playing. Uses only the Flutter SDK (no visibility package).
MovaAutoPauseGate
Pure decision core of the auto-pause guard: tracks the set of active hide reasons and decides when to pause and when to resume. No clock, no Flutter — the caller passes the time in.
MovaAutoPauseOpts
Which visibility changes pause a player, and how it resumes. A pure value used by the MovaAutoPause widget; not part of MovaOpts because it describes one mount point, while a player may be mounted twice (page and mini window).
MovaAutoPauseState
State of MovaAutoPause: collects the four visibility signals and feeds them to a MovaAutoPauseGate.
MovaBrightness
A IMovaBrightness implementation backed by the screen_brightness plugin. Reads the app's current screen brightness and applies changes to it; any plugin error falls back to a brightness of 1.0.
MovaBufferWarm
Buffer-based readiness: ready once the shadow has reached the target position, is not stalled, and holds lookahead of buffered data — for stableTicks consecutive observations. A live shadow (MovaWarmSignal.live) is never required to reach the target position: it starts at the live edge, so only the stall flag and the lookahead decide.
MovaCallbackReporter
Wraps a plain callback as a IMovaReporter (same convenience pattern as MovaCallbackVolume).
MovaCallbackVolume
A IMovaVolume adapter that forwards writes to a plain callback, so a host can control volume without implementing the full interface.
MovaConnectivityNetProbe
The default IMovaNetProbe: treats wifi/ethernet/vpn as unmetered and a mobile-only connection as metered.
MovaCursor
会话只读游标;示例:session.cursor.item 返回已接受的集下标。
MovaCutover
A IMovaApi that owns a live player plus, briefly, a warming shadow one, and presents a single stable surface in front of both.
MovaDefaultRecovery
The policy in effect when MovaRecoveryOpts.policy is null: VOD sources follow vod (the long-standing MovaRetryThenFailover), live sources follow live (MovaLiveReconnect), which keeps reconnecting.
MovaDiskThumbCache
A IMovaThumbCache backed by a directory of files, evicting by total bytes with least-recently-touched-first ordering.
MovaEagerWarm
Warms up immediately, for switch points that are not predictable.
MovaEdgeStall
Default edge-based policy: counts a stall from the rising edge to the falling edge, swallowing anything shorter than minStall (mpv coalesces property-change notifications, so sub-frame flaps are noise, not stalls).
MovaErrorVerdict
Verdict for one playback error: whether it's fatal, and its stable code.
MovaFailoverOnly
Never retries the same address: next alternative if any, else give up.
MovaFallbackBrightness
A zero-dependency IMovaBrightness fallback that always reports full brightness and silently ignores writes.
MovaFallbackVolume
A zero-dependency IMovaVolume fallback that reports full volume and silently ignores writes.
MovaFirstFrameGate
Decides when one playback attempt has actually started presenting media.
MovaFixedThumbDirProvider
A IMovaThumbDirProvider that always returns one fixed path.
MovaFrameExtractor
The default IMovaFramePuller: a second, hidden media_kit Player used only to decode single frames.
MovaHook
Hook points that let hosts veto or rewrite core actions.
MovaHookChain
Runs a list of MovaHooks in order, short-circuiting on veto/cancel.
MovaIoHttpFetcher
The default IMovaHttpFetch, built on dart:io's HttpClient.
MovaItemChange
已接受条目变化;示例:event is MovaItemChange。
MovaLazyNetProbe
按需创建真实探针;仅调用 allowHeavy 或读取 changes 才调用 factory。 未使用便销毁时不会创建探针。示例:MovaLazyNetProbe(makeProbe)。
MovaLeadWarm
Warms up lead before a predictable switch point, and never at all for clips shorter than minDuration.
MovaLiveReconnect
Keeps reconnecting a live source: retries with exponential backoff (capped at maxDelay) instead of giving up, so a publisher that restarts or drops for a while is picked up again automatically. With alternatives, every address but the last is retried retriesPerAddress times before failing over; the last one keeps retrying (until maxAttempts, if set).
MovaLogLine
One error-level log line from the kernel, with the subsystem prefix mpv itself attaches (media_kit's error stream throws this away).
MovaMemoryThumbCache
An in-memory IMovaThumbCache with byte- and count-based LRU eviction.
MovaNodeEnd
节点结束事件;示例:event is MovaNodeEnd。
MovaNodeFail
一次节点失败裁决;示例:event is MovaNodeFail。
MovaNodeId
时间线节点身份;负序号表示运行时插播。示例:MovaNodeId(0, MovaNodeKind.pre, 1)。
MovaNodeStart
节点开始事件;示例:event is MovaNodeStart。
MovaNoopOrient
A zero-dependency IMovaOrient no-op that does nothing.
MovaNoopPip
A zero-dependency IMovaPip no-op that reports PiP as unsupported.
MovaOrient
A IMovaOrient implementation backed by SystemChrome, driving preferred device orientations and immersive system UI mode.
MovaOrientOpts
Host settings restored after fullscreen; defaults to all orientations and edge-to-edge.
MovaPip
A IMovaPip implementation that forwards to MovaPlatform.instance's method-channel calls.
MovaPlayFail
One playback failure, fed to a IMovaRecoveryPolicy.
MovaPrefixError
Default policy built on mpv's log prefixes; see the table in doc/plans/2026-09-29-telemetry-enhancement.md §D4.
MovaPreviewService
The production IMovaPreviewApi: debounces scrub ticks, aligns them to buckets, enforces the network policy, serves cache hits, and walks the configured source chain — one request in flight at a time.
MovaPullerThumbSource
Adapts a IMovaFramePuller to the IMovaThumbSource contract so the preview service can treat extraction as just another entry in its ordered source list.
MovaRecoveryDecision
A policy's answer: an action plus how long to wait before acting.
MovaReportEvent
A single standardized report event.
MovaReportName
Names of every action/event/error mova can currently report, plus any host-defined custom name via MovaReportName.custom.
MovaRetryThenFailover
Retries each address maxRetries times after retryDelay, then moves to the next alternative, then gives up. The default policy.
MovaSession
Orchestrates content and ads on a borrowed player, yielding to host loads.
MovaSessionEvent
独立于播放器事件的会话事件;示例:session.events.listen((e) => print(e.epoch));。
MovaSessionTally
Accumulates one session's watch-time/stall/position tallies.
MovaStall
One completed stall (rebuffer) record.
MovaStatsSnapshot
A single sample of libmpv's playback counters.
MovaSystemVolume
A IMovaVolume backed by the native mova method channel, driving the real system media volume ([0, 100]).
MovaTempThumbDirProvider
A temporary thumbnail directory protected by an OS file lease. First use adopts the newest unowned directory and removes the others; unowned directories older than seven days are always removed.
MovaThumb
One resolved preview frame: encoded image bytes, the sub-rectangle to display, and the bucket-aligned position it represents.
MovaThumbCrop
A rectangular sub-region of a sprite sheet, in image pixels.
MovaThumbCue
One WebVTT thumbnail cue: a time range plus the image (and optional sub-rectangle) covering it.
MovaThumbIndex
A time-ordered set of MovaThumbCues with O(log n) lookup.
MovaTwoLevelCache
Composes a fast synchronous level (memory) over a slow persistent one (disk).
MovaVttThumbSource
A IMovaThumbSource backed by a server-provided WebVTT thumbnail track and its sprite sheets.
MovaWarmCue
What the caller knows about the upcoming switch point.
MovaWarmPlan
Per-warm-up overrides for one IMovaCutover.prepare call.
MovaWarmSignal
One observation of a warming shadow player, fed to a IMovaWarmPolicy.

Enums

MovaCutoverPhase
Which stage of a cutover the player is in.
MovaEndFileReason
mpv's own end-of-file reasons (mpv_end_file_reason), reachable via media_kit master's observeEvent(MPV_EVENT_END_FILE). eof is intentionally absent: media_kit forces --keep-open=yes, under which mpv never truly ends the file on a natural EOF — that case stays covered by MovaDone/completed, not this enum. See doc/plans/2026-09-29-telemetry-enhancement.md §D3's 2026-09-29 update.
MovaFirstFrameSignal
Which observation landed the first frame of a playback attempt.
MovaGuardAction
What the widget should do after a visibility change.
MovaHiddenMode
What the guard does with a playing live stream while it is hidden.
MovaHideReason
Why a player mount is currently considered hidden.
MovaKeepAliveMode
How a held stream is kept running.
MovaKeepAlivePhase
Where a player is in the keepAlive lifecycle.
MovaKeepAliveReason
Why the keepAlive phase changed (events), or why an entry was declined (the last three are decision-only and never appear in events).
MovaLiveResume
How a live source resumes after being hidden.
MovaLoadOutcome
加载结果;接受只表示首段已接管,不保证首帧。示例:result == MovaLoadOutcome.accepted。
MovaNodeEndReason
节点结束原因;示例:MovaNodeEndReason.completed。
MovaNodeFailVerdict
节点失败裁决;示例:event.verdict == MovaNodeFailVerdict.failItem。
MovaNodeKind
节点类型;示例:MovaNodeKind.mid 表示中插。
MovaPlatformKind
The host platform, as far as the preview feature needs to distinguish it.
MovaPlayFailKind
What went wrong with a playback attempt.
MovaPreviewNet
When scrub-preview thumbnails are allowed to use the network.
MovaRecoveryAction
What the player does next.
MovaReportKind
Report event category: a user action, a playback state event, or an error.
MovaReportPriority
Priority hint only — mova never schedules or batches deliveries itself; the IMovaReporter implementation decides whether to send immediately or accumulate a batch.
MovaSessionEnd
Why a playback session ended. Parallel to ExoPlayer's ENDED/STOPPED/FAILED/ABANDONED terminal states.
MovaSessionPhase
会话阶段;示例:session.cursor.phase == MovaSessionPhase.content。
MovaWarmVerdict
The verdict a IMovaWarmPolicy returns for one MovaWarmSignal.

Functions

atLiveEdge(Duration position, Duration window, Duration edgeThreshold) → bool
Whether position counts as sitting at the live edge of window.
behindOf(Duration position, Duration window, Duration edgeThreshold) → Duration?
How far position is behind the live edge of a window, or null when it is close enough to the edge to count as live.
currentPlatformKind() → MovaPlatformKind
Detects the current MovaPlatformKind from dart:io.
defaultCacheKey(String sourceKey, int bucketSec, int width) → String
Builds the default cache key for one thumbnail.
defaultVttUrl(MovaSource source) → Uri?
The conventional thumbnail track location: the media URL with .vtt appended to its path, query and fragment preserved.
fnv1a64(String input) → int
Computes a 64-bit FNV-1a hash of input, masked to a non-negative Dart int.
movaCapturePreviewFrame({required Future<bool> landed(), required Future<Uint8List?> capture(), Future<bool> retrySeek()?, Duration settleDelay = Duration.zero}) → Future<Uint8List?>
Calls capture after landed and settleDelay, optionally retrying a seek once with retrySeek; returns null on failure. See the example below.
movaFetchWithHeaders(IMovaHttpFetch fetcher, Uri url, Map<String, String> headers) → Future<Uint8List?>
优先调用带头能力;旧实现仍调用 get,且每个实例仅在 debug 提示一次。
movaWaitForPreviewFrame(Future<bool> done(), {Duration pollInterval = const Duration(milliseconds: 30), Duration timeout = const Duration(seconds: 5)}) → Future<bool>
Polls done at pollInterval until timeout; returns false on failure. Example: await movaWaitForPreviewFrame(check).
newMovaSessionId() → String
Generates a fresh session id: a pure function, no third-party uuid dependency (mirrors this project's sha1→FNV-1a-style "roll our own instead of a new dependency" tradeoff).
parseVttThumbs(String content, {required Uri base}) → MovaThumbIndex
Parses a WebVTT thumbnail track into a time-ordered MovaThumbIndex.
preferredOrientsFor(int width, int height) → List<DeviceOrientation>
Chooses the fullscreen orientations that match a video's aspect ratio.
previewAllowedOn(MovaPreviewNet policy, IMovaNetProbe probe) → Future<bool>
Resolves policy against probe into a single allow/deny answer.
resolveOrients(MovaOrientMode orient, {required bool fullscreen, required int width, required int height}) → List<DeviceOrientation>
Resolves the device orientations to request, honoring a forced orient override and falling back to the aspect-ratio/fullscreen derivation when it is MovaOrientMode.auto.
resolveSessionEnd({required bool fatalSeen, required bool completed, required bool firstFrame}) → MovaSessionEnd
Classifies how a session ended, per doc/plans/2026-09-29-telemetry-enhancement.md §D3. Pure: every input is explicit so the whole four-way split is unit-testable without a kernel.
resolveSessionEndNative({required MovaEndFileReason? nativeReason, required bool fatalSeen, required bool completed, required bool firstFrame}) → MovaSessionEnd
Same four-way split as resolveSessionEnd, but corroborated by the native MPV_EVENT_END_FILE reason when one arrived before teardown (2026-09-29 update to §D3). MovaDone/completed stays authoritative for ended — media_kit's forced --keep-open=yes means mpv never reports a native eof reason, so completed is still the only signal for that branch. nativeReason null (no native event arrived, or the kernel doesn't support observeEvent) falls back to exactly resolveSessionEnd's behavior — this function is a strict enhancement, not a replacement.
resolveWindow(MovaState s, MovaLiveOpts opts) → Duration
Resolves the seekable DVR/time-shift window for s under opts.

Typedefs

MovaCacheKeyBuilder = String Function(String sourceKey, int bucketSec, int width)
Strategy for building thumbnail cache keys; see defaultCacheKey.
MovaSessionIdFactory = String Function()
Injectable session-id factory type; see MovaReportOpts.sessionId.
MovaVttUrlSolver = Uri? Function(MovaSource source)
Strategy for locating a media's WebVTT thumbnail track.

Exceptions / Errors

MovaGiveUpError
The error placed in MovaState.error once recovery gives up.