loader

Source: loader.js:10

User-interface adapter for the seekable Video Loader. This page analyses existing local videos only; live camera assistance belongs to realtime.html. The model pipeline and the serialisable session live in dedicated modules so Playwright can drive exactly the same behaviour as a person using the page.


Instance Methods

formatMediaTime(seconds: number): string

Formats a media timestamp as mm:ss.mmm or hh:mm:ss.mmm.

Parameters

  • seconds (number) — Media timestamp in seconds.

Returns

  • string — Human-readable timestamp.

formatFileSize(bytes: number): string

Formats source byte size for the compact file identity line.

Parameters

  • bytes (number) — Source file size.

Returns

  • string — Human-readable binary size.

renderAnalysisMessage( kind: 'error' | 'success' | null, title?: string, body?: string, ): void

Shows or clears the persistent analysis notice beside the run controls.

Parameters

  • kind ('error' | 'success' | null) — Notice kind, or null to clear it.
  • title (string, optional) — Short notice heading.
  • body (string, optional) — Actionable explanation.

Returns

  • void

baselineFailureCopy(update: object): Object

Converts a stable controller failure reason into baseline guidance that can be understood without reading the technical log.

Parameters

  • update (object) — Controller failure update.

Returns

  • Object — Visible baseline diagnostic.

seekToMediaTime(mediaTime: number): void

Seeks the source player from report evidence when analysis is idle. During analysis the controller owns media time, so evidence links remain disabled.

Parameters

  • mediaTime (number) — Source timestamp.

Returns

  • void

createMediaTimeButton( mediaTime: number, extraClass?: string, ): HTMLButtonElement

Creates a timestamp that acts as a source-video seek control.

Parameters

  • mediaTime (number) — Source timestamp.
  • extraClass (string, optional) — Optional presentation class.

Returns

  • HTMLButtonElement — Clickable media-time control.

renderAnalysisProgress(update: object): void

Renders baseline calibration or scan-sample progress without pretending that browser media time is a reliable encoded-frame number.

Parameters

  • update (object) — Controller update.

Returns

  • void

setStatus( kind: 'init' | 'ready' | 'working' | 'error', message: string, ): void

Updates the visible application status.

Parameters

  • kind ('init' | 'ready' | 'working' | 'error') — Status kind.
  • message (string) — Human-readable status.

Returns

  • void

dispatchLoaderEvent(type: string, detail?: object): void

Dispatches a stable browser event consumed by Playwright and optional tools.

Parameters

  • type (string) — Event suffix.
  • detail (object, optional, default: "{}") — Serializable detail.

Returns

  • void

downloadText( filename: string, contents: string, mimeType: string, ): void

Starts a browser download without coupling the report and technical log.

Parameters

  • filename (string) — Suggested filename.
  • contents (string) — Text contents.
  • mimeType (string) — MIME type.

Returns

  • void

downloadFrame(filename: string, dataUrl: string): void

Downloads a selected evidence frame from its data URL.

Parameters

  • filename (string) — Suggested filename.
  • dataUrl (string) — JPEG data URL.

Returns

  • void

syncVideoTimeline(): void

Synchronises video labels and the manual seek control.

Returns

  • void

renderBaseSelection(): void

Shows the current scrub position as an explicit baseline action and keeps the already selected reference visible while the person reviews the video.

Returns

  • void

selectCurrentBase(): void

Selects the currently displayed video position as the exact computational and visual baseline. Nearby frames may calibrate noise but cannot replace the selected source timestamp.

Returns

  • void

drawTimeline(session: object | null): void

Draws three separate evidence lanes: MediaPipe presence, ImageEmbedder drift, and sparse face-api distances. Values from different models are never merged into one scale.

Parameters

  • session (object | null) — Current analysis session.

Returns

  • void

createEventCard(event: object, session: object): HTMLElement

Builds one editable evidence card.

Parameters

  • event (object) — Session evidence event.
  • session (object) — Current session.

Returns

  • HTMLElement — Event card.

orderedStoryItems( session: object, ): Array.<{id: string, kind: ('baseline'|'event'), value: object}>

Returns report items in human-controlled story order. Source timestamps are never changed by an editorial move.

Parameters

  • session (object) — Current session.

Returns

  • Array.<{id: string, kind: ('baseline'|'event'), value: object}> — Ordered items.

appendStoryOrderButtons( actions: HTMLElement, itemId: string, session: object, ): void

Adds reversible story-order controls to one evidence card.

Parameters

  • actions (HTMLElement) — Action container.
  • itemId (string) — Event identifier.
  • session (object) — Current session.

Returns

  • void

createBaselineCard( baseline: object, session: object, ): HTMLElement

Builds the pinned computational reference as the first story item. Its source timestamp and role in the distance calculation remain unchanged.

Parameters

  • baseline (object) — Session baseline.
  • session (object) — Current session.

Returns

  • HTMLElement — Reference card.

renderSession(session: object | null): void

Re-renders report summary, timeline, and evidence cards from session state.

Parameters

  • session (object | null) — Current analysis session.

Returns

  • void

getPausedSettingsChanges( session: object | null, requestedSampleInterval: number, requestedBaselineTime: number | null, ): Object

Compares paused-run settings with the editable UI values. It prevents a changed cadence or reference from being presented as a lossless resume.

Parameters

  • session (object | null) — Current analysis session.
  • requestedSampleInterval (number) — Sampling interval requested by the UI or API.
  • requestedBaselineTime (number | null) — Baseline timestamp requested by the UI or API.

Returns

  • Object — Restart reasons.

syncControls(): void

Updates controls after model, file, and analysis state changes.

Returns

  • void

loadSelectedFile(): Promise.<(object|null)>

Loads the file currently selected in the input.

Returns

  • Promise.<(object|null)> — Loaded session, or null when no file exists.

startAnalysis(options?: object): Promise.<object>

Runs analysis using the currently selected sampling interval.

Parameters

  • options (object, optional) — Optional API-provided range and cadence overrides.

Returns

  • Promise.<object> — Completed session.

analyzeCurrentFrame(mediaTime?: number): Promise.<object>

Runs an explicit comparison for the frame currently shown by the source player and adds the result to the editable evidence story.

Parameters

  • mediaTime (number, optional) — Optional timestamp supplied by automation.

Returns

  • Promise.<object> — Created manual evidence event.

init(): Promise.<void>

Initialises localisation and model loading without requesting a camera.

Returns

  • Promise.<void> — Resolves after model loading succeeds or fails.