ranui
Version:
A framework-agnostic Web Components UI library built on native custom elements, with TypeScript types, light/dark theming, SSR and PWA support.
28 lines (27 loc) • 1.42 kB
TypeScript
/**
* QoE (Quality of Experience) accumulator — pure computation layered on the
* `change()` event stream the player already emits, no new UI
* (`docs/PLAYER_ROADMAP.md` Phase 3). Every transition it needs is already a
* `change()` call somewhere else in the player; this module never touches the
* `<video>` or DOM directly.
*/
export interface PlayerMetrics {
/** Number of `waiting`→`playing` transitions observed since the last `onLoadStart()`. */
rebufferCount: number;
/** Total time (ms) spent between a `waiting` and the `playing` that ended it. */
rebufferDuration: number;
/** ms from `onLoadStart()` to the first `canplay`/`playing`, or `null` before either has fired. */
firstFrameMs: number | null;
/** Number of user-triggered quality switches (`qualityswitch` change events). */
qualitySwitchCount: number;
/** Number of `error`/`sourceerror` change events. */
errorCount: number;
}
export interface PlayerMetricsController {
/** Resets all counters and starts the first-frame clock — call at the start of every `updatePlayer()`. */
onLoadStart: () => void;
/** Feed every `change(name, value)` call through this — unrecognized names are ignored. */
record: (name: string, value: unknown) => void;
getMetrics: () => PlayerMetrics;
}
export declare function createMetricsController(now?: () => number): PlayerMetricsController;