Skip to main content
The <helios-player> web component provides a drop-in UI for reviewing and exporting Helios compositions. It implements a subset of the HTMLMediaElement interface for familiar programmatic control.

Installation

npm install @helios-project/player

Usage

Basic setup

Import the player and use the custom element in your HTML:
<script type="module">
  import "@helios-project/player";
</script>

<helios-player
  src="path/to/composition.html"
  width="1920"
  height="1080"
  controls
  autoplay
></helios-player>

Connecting the composition

For the player to control your composition, the composition page must connect to the parent window. Using @helios-project/core:
import { Helios } from "@helios-project/core";
import { connectToParent } from "@helios-project/player/bridge";

const helios = new Helios({ /* config */ });

// Initialize the bridge
connectToParent(helios);
Legacy mode (same-origin only): The player will automatically access window.helios on the iframe’s content window if available. However, connectToParent is recommended for cross-origin support and sandboxing.

Attributes

AttributeDescriptionDefault
srcURL of the composition page to load(Required)
widthWidth for aspect ratio calculation-
heightHeight for aspect ratio calculation-
autoplayAuto-start playback when connectedfalse
loopLoop playback at the endfalse
controlsShow UI controls overlayfalse
export-modeExport strategy: auto, canvas, or domauto
canvas-selectorCSS selector for canvas elementcanvas
export-formatOutput format: mp4, webm, png, jpegmp4
posterImage URL to display before playback-
preloadauto or none (defers iframe loading)auto
input-propsJSON string of composition properties-
interactiveEnable direct composition interactionfalse
controlslistDisable features: nodownload, nofullscreen-
sandboxSecurity flags for the iframeallow-scripts allow-same-origin
export-widthTarget width for export-
export-heightTarget height for export-
export-bitrateTarget bitrate for export (bps)-
export-filenameFilename for export (no extension)video
export-caption-modeCaption strategy: burn-in or fileburn-in
disablepictureinpictureHide Picture-in-Picture buttonfalse
media-titleTitle for OS Media Session-
media-artistArtist name for OS Media Session-
media-albumAlbum name for OS Media Session-
media-artworkArtwork URL for OS Media Session-

User interface

The player includes comprehensive controls:
  • Playback - Play/Pause, scrubber, time display
  • Audio - Volume, mute, and track menu for individual track control
  • Settings menu (gear icon):
    • Speed adjustment (0.25x - 2x)
    • Loop toggle
    • Playback range (In/Out points)
    • Diagnostics (WebCodecs support)
    • Shortcuts reference
  • Tools - Fullscreen, Picture-in-Picture, captions (CC), export

Keyboard shortcuts

KeyAction
Space / KPlay / Pause
FToggle Fullscreen
MMute / Unmute
CToggle Captions
?Show Shortcuts Help
/ Seek 1 frame
Shift + / Seek 10 frames
HomeGo to Start
EndGo to End
ISet In Point
OSet Out Point
XClear Playback Range
Shift + DToggle Diagnostics
0-9Seek to 0-90%

API reference

The <helios-player> element implements a subset of the HTMLMediaElement interface.

Methods

play(): Promise<void>

Starts playback.
const player = document.querySelector('helios-player');
await player.play();

pause(): void

Pauses playback.

load(): void

Reloads the iframe (useful if src changed or to retry connection).

export(options?: HeliosExportOptions): Promise<void>

Programmatically trigger client-side export.
await player.export({
  format: 'webm',
  filename: 'my-video',
  mode: 'dom',
  width: 1920,
  height: 1080
});

diagnose(): Promise<DiagnosticReport>

Runs environment diagnostics (WebCodecs, WebGL) and returns a report.

requestPictureInPicture(): Promise<PictureInPictureWindow>

Requests Picture-in-Picture mode for the player.

addTextTrack(kind: string, label?: string, language?: string): TextTrack

Adds a new text track to the media element.

fastSeek(time: number): void

Seeks to the specified time as fast as possible (currently equivalent to setting currentTime).

Properties

PropertyTypeDescription
currentTimenumberCurrent playback position (seconds)
durationnumber (read-only)Total duration (seconds)
pausedboolean (read-only)Whether playback is paused
endedboolean (read-only)Whether playback has ended
volumenumberAudio volume (0.0 to 1.0)
mutedbooleanAudio mute state
playbackRatenumberPlayback speed (default 1.0)
widthnumberReflected width attribute
heightnumberReflected height attribute
videoWidthnumber (read-only)Intrinsic video width
videoHeightnumber (read-only)Intrinsic video height
bufferedTimeRanges (read-only)Buffered content (always 0-duration)
seekableTimeRanges (read-only)Seekable content (always 0-duration)
seekingboolean (read-only)Whether currently seeking/scrubbing
readyStatenumber (read-only)Readiness state (0-4)
networkStatenumber (read-only)Network state (0-3)
fpsnumber (read-only)Frames per second
currentFramenumberCurrent frame index
inputPropsobjectComposition input properties
playsInlinebooleanReflected playsinline attribute
disablePictureInPicturebooleanHide PiP button
textTracksTextTrackList (read-only)Text tracks

Events

The element dispatches standard media events:
  • play - Playback starts
  • pause - Playback paused
  • ended - Playback completed
  • timeupdate - Current time/frame changed
  • volumechange - Volume or mute state changed
  • ratechange - Playback rate changed
  • durationchange - Duration changed
  • loadstart - Browser begins looking for media
  • loadedmetadata - Duration and dimensions determined
  • loadeddata - Data for current frame available
  • canplay - Browser can resume playback
  • canplaythrough - Browser can play through without buffering

Controllers

The player uses two controller patterns for managing compositions:

DirectController

For same-origin compositions with direct access to the Helios instance. See /home/daytona/workspace/source/packages/player/src/controllers.ts:38

BridgeController

For cross-origin or sandboxed compositions using postMessage communication. See /home/daytona/workspace/source/packages/player/src/controllers.ts:245

Client-side export

The player supports browser-based export to video (MP4/WebM) or image snapshots (PNG/JPEG) using WebCodecs.

Export modes

  • canvas - Captures frames from a <canvas> element. Fast and efficient.
  • dom - Captures the entire DOM using foreignObject SVG serialization. For compositions using DOM elements.
  • auto - Automatically detects the best strategy.

Configuration example

<helios-player
  src="composition.html"
  export-mode="dom"
  export-format="webm"
  export-width="1920"
  export-height="1080"
></helios-player>

Image snapshots

Set export-format="png" or export-format="jpeg" to capture a single frame instead of rendering video.

Audio fades

Apply audio fades during export by adding data-helios-fade-in and data-helios-fade-out attributes to audio elements:
<audio src="music.mp3" data-helios-fade-in="2" data-helios-fade-out="3"></audio>
Values are in seconds.

CSS variables

Customize the player controls with CSS variables:
VariableDefaultDescription
--helios-controls-bgrgba(0, 0, 0, 0.6)Controls bar background
--helios-text-colorwhiteText and icon color
--helios-accent-color#007bffAccent for active elements
--helios-range-track-color#555Scrubber track background
--helios-font-familysans-serifUI font family

Verification

Run the E2E verification suite:
npx tsx tests/e2e/verify-player.ts
This uses Playwright to verify core functionality (playback, scrubber, menus, volume) with a dependency-free mock composition.

Build docs developers (and LLMs) love