Amazon Developer

as

Settings
Sign out
Notifications
Alexa
Amazon Appstore
Ring
AWS
Documentation
Support
Contact Us
My Cases
Get Started
Design and Develop
Publish
Reference
Support
Skip to main content
In this article, you’ll implement closed captions and subtitles in your Vega app using the W3C-compliant text track APIs. Closed captions provide audio transcriptions to help viewers with disabilities or ambient noise, while subtitles translate dialogue into different languages. Text tracks can be broadly divided into two categories:
  • In-band: Text tracks delivered within the media segment, for example, CEA captions and MP4 text tracks (WebVTT/TTML as separate tracks).
  • Out-of-band (OOB): Text tracks delivered as a separate file from the media stream. In ABR streaming, these files are referenced in the playlist or manifest file. In some cases, caption files are associated with media content through a database and aren’t present in the manifest file.

Prerequisites

  • Vega development environment set up
  • Basic knowledge of React Native and TypeScript
  • @amazon-devices/react-native-w3cmedia package version 2.1.14 or later
  • Vega SDK v0.10 or later

Add the required privilege

To add the accessibility privilege, add the following to manifest.toml.

Install the VTTCue polyfill

The @amazon-devices/react-native-w3cmedia package provides a polyfill for VTTCue, which is an implementation of the TextTrackCue interface. Install the polyfill during your app initialization.

Add the KeplerCaptionsView component

The KeplerCaptionsView component renders closed captions and subtitles on screen. Use this component when operating in pre-buffering mode with VideoPlayer and AudioPlayer components. Add the component to your render tree.
Make sure to set the show property to true to render the captions.

Add a text track for app-parsed captions

When your app handles fetching and parsing caption data directly, add a text track to your HTMLMediaElement implementation and populate it with VTTCue objects. This approach applies to any text track that your app parses, whether the source is in-band or out-of-band. If you use a JavaScript player such as Shaka Player, it manages track creation internally and you don’t need to follow this step.

Add cues to the text track

After parsing caption data, add cues to the text track using VTTCue.

Listen for natively parsed text tracks

The platform automatically detects in-band captions like CEA 608 and 708. When media segments are appended to the SourceBuffer, the platform parses these captions in the native layer, which is more efficient than JavaScript-based parsing. Register for the addtrack event to receive notifications when text tracks are detected.

Add a text track with a caption file URL

If your app has the caption file URL but lacks parsing capability, the platform can fetch, parse, and render known subtitle formats. Pass the caption file URL and its MIME type when adding the text track. This approach is not W3C-compliant, is not the recommended method, and is on the deprecation path. When possible, use app-side or JavaScript player-based parsing instead.
The contentUri and contentMimeType parameters are not standard W3C parameters. The following MIME types are supported.
  • application/ttml+xml
  • text/vtt
  • application/x-subtitle
  • application/x-subtitle-sami
  • application/x-subtitle-tmplayer
  • application/x-subtitle-mpl2
  • application/x-subtitle-dks
  • application/x-subtitle-qttext
  • application/x-subtitle-lrc
  • application/x-subtitle-vtt

Select and display a text track

Set the text track mode to showing to render it on screen.
By default, text tracks are added with mode set to hidden.

Use ShakaPlayer for automatic caption parsing

ShakaPlayer can automatically parse and render captions from manifest files and media segments. When using ShakaPlayer, the player handles text track creation and cue management internally, so you don’t need to manually call addTextTrack() or addCue(). Configure ShakaPlayer to enable text track rendering.
After loading content, set text track visibility to true to display captions.
Make sure you’re using Vega SDK v0.21 or later with the ShakaPlayer patches from shaka-rel-v4.6.18-r2.5.tar.gz or newer.

Test the implementation

Build and run your app on a Fire TV device or emulator:
  1. Navigate to a screen with video playback.
  2. Start playing media that contains captions.
  3. Verify that captions appear on screen.
  4. Test switching between different caption tracks if available.

Known limitations

  • Vertical rendering of subtitles is not supported.
  • Custom cue window size is not supported. Captions window size is auto only.
  • If position is not provided in VTTCue, subtitles and captions are positioned at the bottom of the screen to prevent overlapping.
  • Multiple KeplerCaptionsView instances within the same process are not supported.
  • Only up to one CEA 708 native track is supported.
  • Roll-up mode for native captions is not supported. For more details, see Roll-up captions.
  • Native caption tracks don’t include language metadata. The language parameter contains channel identifiers such as CC1, CC2, CC3, and CC4.
  • VTTRegion is not supported.
  • CSS styling of subtitles and captions is not supported.

FAQ

Ideally, native parsing of CEA 608/708 should be enabled and JavaScript-based parsing should be avoided. Apps should parse captions only when native parsing doesn’t work or the app needs access to the caption text.
Use a combined track management strategy:
  • Use a JavaScript player API (for example, ShakaPlayer) for subtitle tracks.
  • Use the VideoPlayer (MediaElement) from the W3C Media API for caption tracks.
The following example queries all available text tracks using this approach.
Use the same combined track management strategy. The following example shows how to select a text track.
When relying on native caption parsing, disable the JavaScript player’s in-band caption parsers to prevent duplicate text tracks.To disable in-band caption parsing in ShakaPlayer, unregister the media segment caption parsers.
If relying on JavaScript in-band parsing instead, use JavaScript player APIs for text track management:
  • Use getTextTracks() to retrieve available text tracks.
  • Use setTextTrackVisibility(isVisible) to enable or disable text tracks.
Yes. The following styling tags are supported:
  • Class span: text color and text background color
  • Italics span
  • Bold span
  • Underline span
For more details, see the WebVTT specification.
VTTRegion is not supported.
CSS styling of subtitles and captions is not supported.

Last modified on June 2, 2026