The OptionsManager is available in TrackPlay player version 6.0+ and is automatically initialized with every player instance.
Overview
The OptionsManager changes player options by dot-notation path, so you can set a nested value and apply it to a running player without rebuilding the whole options object.Key Features
- Dot Notation Access - Use simple paths like
'style_options.main_color' - Batch Operations - Change multiple options efficiently in one call
- Automatic Application - Changes are immediately applied to player components
- Extensible Handlers - Register custom handlers for new option types
- Event Notifications - Listen for option change events
- Type Safety - Built-in validation and error handling
Basic Usage
Setting Single Options
Options can be set immediately when
TrackPlayReady fires. If the OptionsManager is not ready yet, options are automatically queued and applied after player initialization completes, ensuring user settings always take precedence over default options.Batch Option Changes
For multiple changes, usesetMultipleOptions() for better performance:
Getting Current Values
Supported Option Types
Style Options (style_options)
Control visual appearance and UI elements:
Autoplay Options (autoplay_options)
Configure automatic playback behavior:
Progress Options (progress_options)
Configure progress bar behavior:
Playback Options (playback_options)
Control video playback behavior:
Continue Watching Options (continue_watching_options)
The Continue or Restart choice a returning viewer sees.
time is a clock string, MM:SS or HH:MM:SS, not a number of seconds. Passing 30
fails validation.Captions Options (captions_options)
Captions are a list of tracks plus the styling applied to all of them. There is no
enabled key and no language key. A track is selected by its lang, and the one marked
default is the one that shows.
text_color, background_color, font_family, font_weight,
font_size, padding. Each track carries lang, label, default and its cue data.
Smart Orientation Options (smart_orientation_options)
Serves the portrait version of the video to a portrait device.
enabled is the only key. Which video is served is decided by the uploaded portrait
version, not by a switching option.
Turbo Options (turbo_options)
Playback speed, and speed as a test.
Paused Options (paused_options)
The paused state is a designed overlay, not a blank frame.
enabled, template, html, custom_html (required when template is
custom), backdrop_color, and the per-orientation style and canvas blocks.
Thumbnail Options (thumbnail_options)
Configure thumbnail display:
Timed Events Options (timed_events_options)
Configure time-based events:
Pixels Options (pixels_options)
Configure conversion tracking pixels:
Security Options (security_options)
Configure player security features:
Advanced Usage
Event Listening
Listen for option changes to trigger custom behavior:Custom Option Handlers
Register handlers for custom option types if you need to extend the player:Conditional Updates
Apply options based on conditions:Time-Based Updates
Change options at specific times:API Reference
Methods
setOption(path, value, apply = true)
Set a single option using dot notation.
Parameters:
path(string) - Dot notation path to the optionvalue(any) - New value to setapply(boolean) - Whether to immediately apply changes
boolean - Success status
Example:
setMultipleOptions(options, apply = true)
Set multiple options at once for better performance.
Parameters:
options(object) - Object with paths as keys and valuesapply(boolean) - Whether to immediately apply changes
boolean - Success status
Example:
getOption(path)
Get the current value of an option.
Parameters:
path(string) - Dot notation path to the option
any - Current option value
Example:
registerOptionHandler(type, handler)
Register a custom handler for specific option types.
Parameters:
type(string) - Root option type. Nothing stops you reusing an existing name, and no error is raised if you do: registeringstyle_optionssilently replaces the built-in handler for the rest of the page’s life. Pick a name of your own.handler(function) - Handler function(path, value, oldValue) => void
boolean - Success status
Example:
Avoid using existing option type names like
style_options, autoplay_options, etc. Use your own namespace like custom_options or my_app_options.Events
option-changed
Fired when any option is changed via the OptionsManager.
Event Data:
Common Use Cases
A/B Testing
User Preferences
Fullscreen Configuration
Configure different fullscreen behaviors for desktop and mobile:Best Practices
Option Precedence
User-set options always take precedence over player defaults:Performance
- Use
setMultipleOptions()for batch changes instead of multiplesetOption()calls - Set
apply: falsewhen making multiple sequential changes, then apply manually - Avoid frequent option changes during video playback
Error Handling
Type Safety
AI Segments (ai_segments_options)
If you use ElevenLabs-powered AI voice segments, the ai_segments_options group (enable flag, preload timing, segment list, voice IDs, prompts, volumes) can be updated at runtime with setOption / setMultipleOptions like other nested options, provided your deployed player build includes the AI Segments feature.
See ElevenLabs & AI Segments for setup, trackplay_data, and viewer experience (including unmute behavior).
Troubleshooting
Common Issues
Option not applying:- Verify the option path is correct
- Check if the component supports dynamic updates
- Ensure the OptionsManager is initialized
- Use batch operations for multiple changes
- Avoid rapid sequential option changes
- Consider debouncing frequent updates
- Always clean up event listeners
- Remove custom handlers when no longer needed
- Call
player.destroy()when removing player