Skip to main content
OptionsManager changes player configuration after the player has loaded. You can retune the player at runtime without reloading it.
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, use setMultipleOptions() 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 option
  • value (any) - New value to set
  • apply (boolean) - Whether to immediately apply changes
Returns: 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 values
  • apply (boolean) - Whether to immediately apply changes
Returns: boolean - Success status Example:

getOption(path)

Get the current value of an option. Parameters:
  • path (string) - Dot notation path to the option
Returns: 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
Returns: 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 multiple setOption() calls
  • Set apply: false when making multiple sequential changes, then apply manually
  • Avoid frequent option changes during video playback

Error Handling

Type Safety

Dynamic option changes are applied immediately to the running player. Some changes may cause visual flicker or interruption of user experience. Test thoroughly in your specific use case.

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
Performance issues:
  • Use batch operations for multiple changes
  • Avoid rapid sequential option changes
  • Consider debouncing frequent updates
Memory leaks:
  • Always clean up event listeners
  • Remove custom handlers when no longer needed
  • Call player.destroy() when removing player

Debug Mode

Enable debug logging to see option changes: