Table of Contents

Subtitles

alt_text

Various subtitles formats are supported:

WebVTT
in HLS
CEA / EIA
608 & 708
tx3g
in MP4 / MOV
SRT
Sideloading
Windows (WinRT / Media Foundation) .
Windows (DirectShow) . . .
Android (ExoPlayer) . .
Android (MediaPlayer) . . .
macOS .
iOS/tvOS/visionOS . .
WebGL . . .

When loading media that contains subtitles tracks, the tracks are displayed in the Inspector allowing tracks to be selected and a preview of the subtitle content to be shown:


alt_text

Text tracks can be scripted:

// Get the number of text tracks
int trackCount = mediaPlayer.TextTracks.GetTextTracks().Count;

// Iterate through the tracks
foreach (TextTrack track in mediaPlayer.TextTracks.GetTextTracks())
{
	Debug.Log(track.DisplayName);
}

// Get information about the active text track
TextTrack track = mediaPlayer.TextTracks.GetActiveTextTrack();
if (track != null)
{
	Debug.Log(string.Format("{0}:{1}", track.Name, track.Language));
}
else
{
	Debug.Log("No active text track");
}

// Set the active text track
mediaPlayer.TextTracks.SetActiveTextTrack(track);

// Get the current text cue
TextCue textCue = mediaPlayer.TextTracks.GetCurrentTextCue();
if (textCue != null)
{
	Debug.Log(textCue.Text);
}

SRT Sideloading

alt_text

AVPro Video supports external subtitles in the SRT format on all platforms.

// Load subtitles
mediaPlayer.SideloadSubtitles = true;
mediaPlayer.EnableSubtitles(MediaLocation.RelativeToStreamingAssetsFolder, "subtitles.srt");

// Disable subtitles
mediaPlayer.DisableSubtitles();

Displaying

You can create your own system to display subtitles, or use the included SubtitlesUGUI component.