Tutorials - Advanced Use

Javascript Code Snippets

Select, copy snippet and paste into the "Actions" fields (onReady, onClick, onStart, etc.)




CSS Code Snippets

Select, copy snippet and paste into the "Custom CSS" fields

see Getting Started > Layout Areas

see Getting Started > Layout Areas


Player Initialization

The FrameTrail player can be initialized directly on your own page in several ways. See the examples folder on GitHub for working implementations of all options below.

Option 1: Adopt an existing <video> element

Point FrameTrail at a <video> tag already on your page. FrameTrail wraps it and takes control of playback.

Option 2: Explicit container with video URL

Provide an empty <div> container and pass the video URL directly as an init option.

Option 3: Data-attribute auto-init

Decorate one or more <video> elements with data-frametrail attributes and call FrameTrail.autoInit() once. Useful when rendering multiple players on a single page.

Supported data attributes:

  • data-frametrail — marks the element for auto-initialization
  • data-frametrail-annotations — URL of a W3C annotations JSON file
  • data-frametrail-language — language code, e.g. en-US
  • data-frametrail-config — inline JSON configuration object

Initialization Options Reference

OptionPurpose
targetContainer selector or DOM element to render the player into
videoElementSelector of an existing <video> element to adopt
videoSourceDirect video URL (MP4, HLS, YouTube, Vimeo, …)
annotationsURL string, array of URLs, or inline W3C annotation objects
languageLanguage code for the UI (e.g. en-US, de-DE)
configConfiguration object — theme, autohideControls, layout defaults, etc.
dataPathBase URL for the _data/ directory (e.g. '../_data/' or a CDN URL); auto-detected when omitted
serverBase URL for the _server/ PHP backend; auto-detected when omitted (set dataPath without this to force static/CDN mode)
startIDID of the hypervideo to open on load
contentsArray of inline hypervideo and annotation data (bypasses _data/ entirely)
resourcesArray of inline resource definitions

Using dataPath and server

When the embedding page is in a subdirectory or on a different host than the FrameTrail installation, set dataPath and server explicitly so requests resolve correctly. If both are omitted, FrameTrail auto-detects by probing the default _server/ path. Providing dataPath without server enables static/CDN mode — read-only access to data without a PHP backend.

Inline data — no server required

Pass the complete hypervideo and resource data directly as init options. FrameTrail never touches the _data/ directory, making this approach work in all four storage modes — including in-memory, local folder, and static/CDN mode. Useful for publishing a single self-contained hypervideo.