Login

Switch subtitles and audio tracks

Subtitle switching and multi-track audio are key features of the FastPix Player that enhance user experience by offering flexible subtitle options and customizable audio track selections. This guide will walk you through how these functionalities work, how to integrate them, and best practices for implementation.


How it works:

  • Manifest parsing: The player parses the metadata within the HLS manifest to detect subtitle entries.
  • Subtitle button activation: If the manifest includes subtitle tracks, the subtitle button in the player interface is activated, making it easy for users to see their options.

Default subtitle selection

The FastPix Player is designed to select the first subtitle track listed in the manifest and
display it automatically when playback begins.


User interface for subtitle switching

The subtitle switching feature consists of two main components that make it user-friendly:

  • Subtitle button: This button appears in the player's toolbar and becomes active when subtitle tracks are detected in the manifest.
  • Subtitle menu: When users click the subtitle button, a menu opens, listing all detected subtitle tracks by language or description. Users can also choose an "Off" option to turn off subtitles.

How users interact with the subtitle menu

  • Default display: When a video starts, the first available subtitle track is shown as the default.
  • Switching subtitles: Users can select their preferred subtitle track from the menu, and the player will instantly switch to display the chosen track.
  • Disabling subtitles: If viewers prefer no subtitles, they can simply choose the "Off" option in the menu to stop subtitle rendering.
  • Controlling subtitle visibility: Users have full control over whether they see subtitles, even if they’re available in the stream.


Implementation details

To implement subtitle switching, a few important steps need to be followed:


1. Manifest configuration: Ensure that your HLS manifest includes correctly formatted entries for subtitle tracks. This includes details like the language, whether the track is the default, and the URI for the subtitles.

Example HLS manifest entry:

EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="subs",LANGUAGE="en",NAME="English",DEFAULT=YES,AUTOSELECT=YES,URI="subtitles/eng/prog_index.m3u8"


2. Player integration: When initializing the FastPix Player, make sure it’s configured to parse the HLS manifest and detect subtitle tracks so that the subtitle button can be activated.


3. User interface updates: The subtitle button should be enabled, and the subtitle menu should be populated with the detected tracks, including an "Off" option for easy subtitle management.


4. Event handling: Set up event listeners to handle user interactions with the subtitle menu:

  • Ensure that the player's subtitle renderer updates to display the chosen subtitle track.
  • Disable subtitle rendering if the user selects "Off".

Example implementation:

Here’s a basic example of how to configure the FastPix Player to support subtitle switching:

<fp-player 
  playback-id="your-playback-id" 
   token="{JWT}"
  stream-type="on-demand" 
/> 

Disable hidden captions

The disable-hidden-captions feature enhances subtitle behavior by ensuring only the selected or active caption is visible, preventing overlapping or hidden captions from rendering.

<fp-player playback-id="your-playback-id" disable-hidden-captions></fp-player> 

Multi-track audio

In addition to subtitle switching, FastPix Player’s support for multi-track audio gives viewers the option to switch between different audio tracks. This feature is especially useful for videos available in multiple languages.


Audio track handling

When the FastPix Player processes an HLS stream, it incorporates any additional audio tracks embedded in the stream URL. The player, like many other modern video players, supports multi-track audio without additional setup.


Switching audio tracks

Switching between audio tracks is straightforward and user-friendly. Here’s what users can do:

  • Interface navigation: Users can access an audio selection menu or control panel to choose their preferred audio track.
  • Intuitive controls: In the FastPix Player, this could be represented by an audio icon or a similar visual element for easy track selection.

Example integration: To set up FastPix Player with multi-track audio support, use the following configuration:

<fp-player  
  playback-id="your-playback-id"  
  token="your-JWT"  
  stream-type="on-demand"  
/>