<hyperframes-player> custom element that embeds a
HyperFrames composition in plain HTML or a framework application.
Embed a composition
Via CDN
index.html
index.html
autoplay muted only when playback should start without a user gesture.
Add or remove controls at any time. When shown, the controls reflect the current
playback state, position and speed. Clicking or dragging the scrubber keeps a
playing film playing from the new spot, as a <video>’s own controls do, and
leaves a paused film paused.
Attributes
range-start and range-end play the moment [start, end) of the film. The player parks on range-start at ready, and again when a paused playhead falls outside a new range; play() from outside the range starts there. At the end it holds the last frame before range-end and fires ended, or wraps to range-start with loop. currentTime at ended is then inside that frame, not range-end itself, so listen for ended rather than comparing times. A current runtime stops on that frame itself; video and __timelines players stop one clock tick early, predicted from the smaller of their last two steps, and a video in a background tab checks on its own timeupdate; an older runtime stops when the player sees its time pass the end. currentTime and duration stay in film time. A range past the film is cut to its end and an empty or negative one is ignored; both fire rangeclamped.
The fullscreen button fills the screen with the whole player, controls included. It appears only where the page can go fullscreen, so not on iPhone Safari and not inside a cross-origin iframe without allow="fullscreen". It follows every exit, including Esc. Set disable-fullscreen to hide it. A refused request fires the browser’s fullscreenerror on the player.
Player also accepts shader-capture-scale and shader-loading for previewing
projects that use shader transitions. These are preview controls, not composition
authoring attributes.
With a video/... type, src plays in a <video> behind the same playback API and
events. scenes, setRuntimeData(), setColorGrading(), iframeElement and stopMedia()
are composition-only, and srcdoc wins over a video src, as it does in an iframe.
Removing a video player’s src attribute or setting it to an empty string unloads the film and resets playback to paused at 0:00. Set a new src to load another video.
JavaScript API
The main API follows familiar media-player behavior:seek() and setting currentTime pause at the new time. Pass { keepPlaying: true }
to keep a playing film playing from there, as setting a <video>’s currentTime
does; a paused film stays paused.
In Studio previews, scrubbing keeps the last complete picture visible while video
layers decode at the requested time. Rapid seeks keep only the latest queued
destination, and the captions and video layers appear together once it is ready.
Complete intermediate pictures can appear during a drag. Jumping to a different
clip supersedes an earlier pending seek; failed sources do not hold up the preview.
Events
Custom icons and loading mark
Put an element with aslot attribute inside the player to replace a control glyph or the loading mark. Anything you leave out keeps the default.
index.html
currentColor, and you set their size. Put slot on the <svg> or <img> itself, as a direct child of the player; a wrapper element needs display: contents to keep the glyph centered. A custom mark replaces the HyperFrames light sweep and glow, so add your own CSS animation if you want motion.
Until the element is defined, its children show as plain content. Hide them:
styles.css
Advanced: iframe access
The composition runs inside an<iframe> in the player’s Shadow DOM. For most
uses, the JavaScript API and events above are enough. The iframeElement getter
exists for same-origin tools that must inspect the composition DOM or connect a
custom editing surface:
@hyperframes/studio exports resolveIframe for consumers
that need to pass the inner iframe to Studio’s timeline hooks:
How it works
The composition runs in a sandboxed iframe inside the player’s Shadow DOM. This isolates its styles, scales it to the player container, and lets the player communicate with the HyperFrames runtime throughpostMessage. Set
sandbox-origin="opaque" to seal the frame, so the composition cannot read
your page or its cookies. The player adds the runtime itself to a composition
from your own site; a composition from another site must include the runtime
script.