- 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-w3cmediapackage 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.
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 yourHTMLMediaElement 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 usingVTTCue.
Listen for natively parsed text tracks
The platform automatically detects in-band captions like CEA 608 and 708. When media segments are appended to theSourceBuffer, 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.contentUri and contentMimeType parameters are not standard W3C parameters.
The following MIME types are supported.
application/ttml+xmltext/vttapplication/x-subtitleapplication/x-subtitle-samiapplication/x-subtitle-tmplayerapplication/x-subtitle-mpl2application/x-subtitle-dksapplication/x-subtitle-qttextapplication/x-subtitle-lrcapplication/x-subtitle-vtt
Select and display a text track
Set the text track mode toshowing to render it on screen.
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 calladdTextTrack() or addCue().
Configure ShakaPlayer to enable text track rendering.
true to display captions.
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:- Navigate to a screen with video playback.
- Start playing media that contains captions.
- Verify that captions appear on screen.
- 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
KeplerCaptionsViewinstances 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
Do apps need to parse in-band captions if the platform supports native CEA 608/708 parsing?
Do apps need to parse in-band captions if the platform supports native CEA 608/708 parsing?
The ShakaPlayer API doesn't report natively parsed caption tracks. How can the app detect them?
The ShakaPlayer API doesn't report natively parsed caption tracks. How can the app detect them?
- Use a JavaScript player API (for example, ShakaPlayer) for
subtitletracks. - Use the
VideoPlayer(MediaElement) from the W3C Media API forcaptiontracks.
How do you enable or disable text tracks?
How do you enable or disable text tracks?
Enabling caption parsing by the JavaScript player reports duplicate text tracks. How can this be avoided?
Enabling caption parsing by the JavaScript player reports duplicate text tracks. How can this be avoided?
- Use
getTextTracks()to retrieve available text tracks. - Use
setTextTrackVisibility(isVisible)to enable or disable text tracks.
Is subtitle and caption styling supported?
Is subtitle and caption styling supported?
- Class span: text color and text background color
- Italics span
- Bold span
- Underline span
Is VTTRegion supported?
Is VTTRegion supported?
Is CSS styling of subtitles and captions supported?
Is CSS styling of subtitles and captions supported?

