Subtitles and Text Tracks
React Native Video supports text tracks for subtitles, captions, and multiple languages. This guide covers how to add and manage text tracks in your video player.Text Track Support
React Native Video supports multiple subtitle formats:- WebVTT (
.vtt) - Recommended, widely supported - SubRip (
.srt) - Common format - SubStation Alpha (
.ssa) - Advanced SubStation Alpha (
.ass)
Adding External Subtitles
Provide subtitle files via theexternalSubtitles array:
External Subtitle Properties
| Property | Type | Required | Description |
|---|---|---|---|
uri | string | Yes | URL or local path to the subtitle file |
label | string | Yes | Display label for the track |
type | 'vtt' | 'srt' | 'ssa' | 'ass' | 'auto' | No | Subtitle format (auto-detected from URI if omitted) |
language | string | No | ISO 639-1 or ISO 639-2 language code |
Auto-Detecting Subtitle Type
If the URI ends with the file extension, you can omit thetype:
If the URI doesn’t end with the file extension, you must explicitly specify the
type.Local Subtitle Files
Use local subtitle files bundled with your app:Managing Text Tracks
Get Available Tracks
Retrieve all available text tracks:TextTrack Interface
TheTextTrack object contains:
Select a Text Track
Programmatically select a subtitle track:Get Selected Track
Access the currently selected track:Track Change Events
Listen to track selection changes:Subtitle Text Events
Receive the actual subtitle text being displayed:Complete Subtitle Selector Example
Platform-Specific Notes
iOS
- Only WebVTT (
.vtt) subtitles are supported for HLS streams and MP4 files - The
labelproperty can be overridden by the player - Embedded subtitles in HLS streams are automatically detected
Android
- Supports WebVTT, SRT, SSA, and ASS formats
- Subtitles work with both DASH and HLS streams
- Text styling is preserved from subtitle files
HLS Embedded Subtitles
For HLS streams with embedded subtitles, tracks are automatically detected:Best Practices
1. Use WebVTT Format
WebVTT is the most widely supported format across platforms:2. Provide Language Codes
Always include language codes for proper identification:3. Handle Track Loading
Wait for video to load before accessing tracks:4. Remember User Preference
Store and restore the user’s subtitle preference:Troubleshooting
Subtitles Not Showing
- Verify the subtitle file format is correct
- Check that the URI is accessible
- Ensure the video has loaded (
onLoadevent fired) - Confirm a track is selected:
player.selectedTrack
Wrong Encoding
Subtitle files should use UTF-8 encoding. Convert files if needed:Timing Issues
Ensure subtitle timestamps match video timing:iOS Label Override
If iOS overrides your labels, rely onlanguage codes instead:
Next Steps
- Learn about Event Handling for advanced subtitle interactions
- Explore Streaming for HLS content with embedded subtitles
- Implement Accessibility features with subtitles