The OptionsManager is available in TrackPlay player version 6.0+ and is automatically initialized with every player instance.
Overview
The OptionsManager provides a clean API for modifying player options using dot notation paths, making it easy to change nested configuration values and immediately apply them to running player instances.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)
Control continue watching functionality:
Captions Options (captions_options)
Configure subtitle/captions display:
Smart Orientation Options (smart_orientation_options)
Handle video orientation detection:
Turbo Options (turbo_options)
Control turbo/speed functionality:
Paused Options (paused_options)
Control paused state behavior:
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 (must not conflict with existing types)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
