Skip to content

ReferenceMedia

HyperFramesVideo

Unstable

Video component that plays HyperFrames compositions, HTML clips animated by a seekable timeline

A HyperFrames composition is HTML clips timed with data-start and data-duration (see the HyperFrames HTML schema), animated by a seekable timeline, usually GSAP. HyperFramesVideo plays one in an iframe under the HyperFrames runtime and drives it as media, so a player skin’s controls, time slider, and keyboard shortcuts work against it. A composition has no chrome of its own, so place it inside a skin.

Import

pnpm add @videojs/hyperframes-video
import { HyperFramesVideo } from '@videojs/react/media/hyperframes-video';

Load a composition file

src takes the URL of a composition document, the HTML file HyperFrames tooling writes. It’s fetched, so a cross-origin file needs CORS. The document plays in an opaque, sandboxed frame that keeps its scripts away from the page, with the runtime injected ahead of them and its relative URLs resolved against src. It registers its own timeline on window.__timelines, as HyperFrames compositions do.

<HyperFramesVideo src="/compositions/intro.html" />

To play a document you already hold as a string, pass it as html instead.

Write a composition inline

An inline composition is markup the page owns. It plays in a same-origin frame, so its timeline is built by the page, from the page’s own GSAP: timeline receives the composition root once the markup is in the frame, and returns the timeline. The element registers it on window.__timelines for you, which a composition file does itself (see GSAP animation in HyperFrames). Scope selectors to root so they only reach this composition. Any object with duration(), seek(time), and pause() works in place of a GSAP timeline. The runtime pauses it and seeks it to the playhead on every frame, and its duration() is the composition’s duration.

The markup renders inside the composition frame, so the page’s styles don’t reach it; carry its styles with it. Its root is 1920×1080 unless the markup declares data-width and data-height, and is named main unless it declares data-composition-id, the root attributes HyperFrames reads.

Write the composition as children; they render into the composition frame through a portal. A re-render updates the composition in place without restarting playback. A new compositionId loads a new composition. compositionId, width, and height fill in the root’s data-composition-id, data-width, and data-height when the markup doesn’t set them.

<HyperFramesVideo
  timeline={(root) =>
    gsap.timeline().from(root.querySelector('.title'), { y: 80, opacity: 0, duration: 1 }, 0)
  }
>
  <style>{`.title { position: absolute; top: 320px; left: 160px; font-size: 140px; color: #fff; }`}</style>
  <h1 className="clip title" data-start="0" data-duration="5" data-track-index="1">
    Hello
  </h1>
</HyperFramesVideo>

Behavior

  • The composition stays hidden until the runtime reports its timeline, so clips don’t flash. A composition that reports none within 15 seconds fails with MEDIA_ERR_SRC_NOT_SUPPORTED.
  • The iframe takes no pointer events; the skin above it handles them.
  • autoplay, muted, and loop reach the composition. controls is ignored, and playsInline, preload, and poster are stored without effect.
  • The composition reports no text tracks; it draws its own captions.
  • HyperFrames variables, chapters from the runtime’s scenes, and unmuted media playback on mobile aren’t supported.
  • The runtime loads from a pinned jsDelivr copy of @hyperframes/core, with subresource integrity. Set runtimeSrc to load another build, such as a self-hosted copy; it loads without integrity, and applies from the next composition.

Examples

Basic Usage

0:00
import { HyperFramesVideo } from '@videojs/react/media/hyperframes-video';
import { VideoPlayer, VideoSkin } from '@videojs/react/video';

import '@videojs/react/video/skin.css';

export default function BasicUsage() {
  return (
    <VideoPlayer>
      <VideoSkin className="react-hyperframes-video-basic">
        <HyperFramesVideo src="/docs/demos/hyperframes-video/intro.html" playsInline />
      </VideoSkin>
    </VideoPlayer>
  );
}