TikTok for Developers

Developer Docs

Last updated November 24, 2026

Add Subtitles to Mini Drama Player

Mini Drama Player can display subtitles from three sources: subtitles returned with the episode's media information, subtitle tracks declared in a Master M3U8 playlist, and subtitle files your mini app provides. Available tracks appear in the player's subtitle menu, where viewers can choose a language or turn subtitles off.

Prerequisites

  • You have integrated Mini Drama Player.
  • Your subtitle files exist. The player doesn't generate subtitles.
  • Subtitle URLs are accessible from the TikTok app, with CORS configured for cross-origin requests.

Supported formats

External subtitle files can be WebVTT, SRT, ASS, or SSA. For ASS and SSA, the player displays text only, without complex layout, effects, or styling. Subtitle tracks in a Master M3U8 are parsed by the HLS engine, so this format list doesn't apply to them.

Choose a subtitle source

The following table lists how to configure each source:

Source

Configuration

Subtitles returned with media information

Set autoSubtitle: true and Subtitle: {}. Use formatAutoSubtitleItem to filter, sort, or choose a default track.

Tracks declared in a Master M3U8

Use the HLS plugin and set Subtitle: {}. Don't enable autoSubtitle or set Subtitle.list.

Subtitle files your mini app provides

Set Subtitle.list.

Automatic subtitles replace Subtitle.list. A non-empty Subtitle.list takes precedence over Master playlist tracks.

Display subtitles from media information

This is the most common setup for mini dramas.

  1. Upload one subtitle file per language with Upload Mini Drama Subtitles, linked to the episode's video.
  2. When you create the player, set autoSubtitle: true and register the subtitle plugin with Subtitle:
const VePlayer = await TTMinis.getPlayer();

const playerSdkIns = new VePlayer({
  id: 'player-container',
  albumId: videoInfo.album_id,
  episodeId: videoInfo.episode_id,
  autoSubtitle: true,
  Subtitle: {
    isDefaultOpen: true,
    isShowIcon: true,
  },
});

The player parses subtitles after it retrieves media information, so the subtitle list updates asynchronously. Don't assume it's ready immediately after you create the player.

The player converts each subtitle's language or language_id to the language's native name for display, such as English, 简体中文, or 日本語. See Language display names.

Display subtitles from a Master M3U8

For a Master playlist that declares subtitle tracks, register the subtitle plugin and leave autoSubtitle disabled:

const VePlayer = await TTMinis.getPlayer();

const playerSdkIns = new VePlayer({
  id: 'player-container',
  url: masterUrl,
  streamType: 'hls',
  enableMobileHlsPlugin: true,
  Subtitle: {}, // Register the subtitle plugin with default settings
});

Tracks appear in the menu after the playlist is parsed. To hide subtitles until the viewer selects a track, set Subtitle: { isDefaultOpen: false }.

Provide your own subtitle files

To display subtitle files your mini app hosts, set Subtitle.list:

const playerSdkIns = new VePlayer({
  // Other player options
  autoSubtitle: false,
  Subtitle: {
    isDefaultOpen: true,
    list: [
      {
        id: 'sub-zh',
        language: 'zh-CN',
        text: '简体中文',
        url: 'https://example.com/episode-1.zh.vtt',
        isDefault: true,
      },
      {
        id: 'sub-en',
        language: 'en-US',
        text: 'English',
        url: 'https://example.com/episode-1.en.vtt',
      },
    ],
  },
});

Configuration reference

autoSubtitle

Property

Type

Default

autoSubtitle

Boolean

false

If true, the player converts the subtitle_info_list returned with media information into the subtitle list.

formatAutoSubtitleItem

Property

Type

Default

formatAutoSubtitleItem

(item, index) => result

undefined

A synchronous callback that runs for each automatic subtitle. It applies only to subtitles from media information, not to Subtitle.list or Master playlist tracks. Return a value directly, not a Promise.

The callback receives the following parameters:

Parameter

Type

Description

item

Record<string, any> or string

The raw subtitle item returned by the server.

index

number

The item's zero-based position in the original list.

Each item object can contain the following fields:

Field

Type

Description

subtitle_id

string

The subtitle ID.

language

string

The language tag, such as cmn-Hans-CN or eng-US.

language_id

number

The language ID, such as 1 for Simplified Chinese.

format

string

The subtitle format, such as webvtt.

subtitle_url

string

The URL of the subtitle file.

source

string

The subtitle source, such as MT for machine translation.

status

string

The subtitle status, such as enable.

title

string

The subtitle title. Used as the display name when the language isn't in the mapping table.

tag

string

The subtitle tag.

file_id

string

The file ID.

store_uri

string

The storage URI.

vid

string

The video ID.

The return value controls how the player handles the item:

Return value

Behavior

string or number

Uses the value as the display name.

true or undefined

Keeps the default result.

false or null

Removes the item from the list.

{ label }

Uses label as the display name.

{ show: false } or { visible: false }

Removes the item from the list.

{ order: number }

Sets the sort order. Lower values appear first. Can be combined with label.

{ isDefault: true } or { default: true }

Selects the item by default. Can be combined with label and order.

Subtitle

Subtitle: {} registers the subtitle plugin with default settings. When autoSubtitle is enabled, the server response populates list.

Property

Type

Default

Description

list

ISubTitleItem[]

[]

The subtitle list. Populated automatically when autoSubtitle is enabled.

isDefaultOpen

Boolean

true

If true, subtitles are shown when playback starts.

isShowIcon

Boolean

true

If true, shows the subtitle menu button.

position

string

controlsRight

The position of the button in the controls.

index

number

60

The order of the button. Lower values appear further right.

style

ISubtitleStyle

See the following table.

The subtitle style.

label

object

N/A

Custom menu labels. See Customize subtitle labels.

style accepts the following properties:

Property

Type

Default

Description

follow

Boolean

true

If true, subtitles move up when the control bar appears.

followBottom

number

50

The offset, in pixels, when subtitles follow the control bar.

fitVideo

Boolean

true

If true, subtitle size and position fit the video frame. Also affects positioning when follow is enabled.

offsetBottom

number

4

The distance from the bottom of the video frame, as a percentage.

mode

'stroke' or 'bg'

'stroke'

The text style. stroke outlines the text. bg adds a solid background.

baseSizeX

number

49

The base font size for landscape video.

baseSizeY

number

28

The base font size for portrait video.

minSize

number

16

The minimum font size on desktop.

minMobileSize

number

13

The minimum font size on mobile.

line

'single', 'double', or 'three'

'double'

The maximum number of lines.

fontColor

string

'#fff'

The font color, as a hex or RGB value.

Caution: style replaces the default style object instead of merging with it. If you set only style: { follow: true }, fitVideo isn't set, and subtitles move up when the controls appear. To keep the default fit, include fitVideo: true.

Each ISubTitleItem in list accepts the following properties:

Property

Type

Description

id

string or number

The subtitle ID.

language

string or number

The language tag.

text, label

string or number

The display name.

url

string

The URL of the subtitle file.

stringContent

string

Inline subtitle content, in WebVTT or SRT format.

list

IListItem[]

Structured subtitle content, used instead of a URL.

isDefault, default

Boolean

If true, the subtitle is selected by default.

const playerSdkIns = new VePlayer({
  // Other player options
  autoSubtitle: true,
  Subtitle: {
    isDefaultOpen: true,
    isShowIcon: true,
    style: {
      follow: true,
      fitVideo: true,
      mode: 'stroke',
      offsetBottom: 4,
      line: 'double',
      fontColor: '#fff',
    },
  },
});

Language display names

For automatic subtitles, the player looks up language_id or language in a built-in table and displays the language's native name:

language

language_id

Display name

cmn-Hans-CN

1

简体中文

eng-US

2

English

jpn-JP

3

日本語

kor-KR

4

한국어

cmn-Hans-CN|eng-US

5

中英双语

rus-RU

6

Русский

fra-FR

7

Français

por-PT

8

Português

spa-ES

9

Español

vie-VN

10

Tiếng Việt

deu-DE

20

Deutsch

ita-IT

26

Italiano

ara-SA

34

العربية

cmn-Hant-CN

36

繁體中文

hin-IN

42

हिन्दी

If the language isn't in the table, the player uses the first available value in this order: title, label, text, language, tag, then language_id. For the full language list, see BytePlus VOD subtitle languages.

Examples

Merge each example into your player configuration.

Hide subtitles until the viewer selects a track

autoSubtitle: true,
Subtitle: {
  isDefaultOpen: false,
  isShowIcon: true,
},

Select a default language

isDefault chooses the default track. isDefaultOpen controls whether it's visible when playback starts. If more than one track is marked as default, the first one in the final list applies. If none is marked, the player selects the first track.

autoSubtitle: true,
formatAutoSubtitleItem: (item) => {
  if (!item || typeof item !== 'object') return true;
  // Select English by default
  if (item.language === 'eng-US') {
    return { isDefault: true };
  }
  return true;
},
Subtitle: { isDefaultOpen: true },

To sort English first, remove machine-translated tracks, and select English by default:

formatAutoSubtitleItem: (item, index) => {
  if (!item || typeof item !== 'object') return true;
  if (item.source === 'MT') return false;
  return {
    order: item.language === 'eng-US' ? 0 : index + 1,
    isDefault: item.language === 'eng-US',
  };
},

Select the viewer's language

navigator.language returns the WebView's language preference, which can differ from the phone's system language. The following example maps common language codes to subtitle tags. You can match on language_id instead, such as Number(item.language_id) === 1.

const SYSTEM_LANG_TO_SUBTITLE_LANGUAGE = {
  'zh-hant': 'cmn-Hant-CN', // Traditional Chinese
  zh: 'cmn-Hans-CN', // Simplified Chinese
  en: 'eng-US',
  ja: 'jpn-JP',
  ko: 'kor-KR',
  ru: 'rus-RU',
  fr: 'fra-FR',
  pt: 'por-PT',
  es: 'spa-ES',
  vi: 'vie-VN',
  de: 'deu-DE',
  it: 'ita-IT',
  ar: 'ara-SA',
  hi: 'hin-IN',
};

function getSystemSubtitleLanguage() {
  const lower = (navigator.language || navigator.languages?.[0] || '').toLowerCase();
  const iso = lower.split('-')[0];
  if (iso === 'zh') {
    const isHant = lower.includes('hant') || /\b(tw|hk|mo)\b/.test(lower);
    return SYSTEM_LANG_TO_SUBTITLE_LANGUAGE[isHant ? 'zh-hant' : 'zh'];
  }
  return SYSTEM_LANG_TO_SUBTITLE_LANGUAGE[iso] ?? null;
}

const systemSubtitleLanguage = getSystemSubtitleLanguage();

const playerSdkIns = new VePlayer({
  // Other player options
  autoSubtitle: true,
  formatAutoSubtitleItem: (item) => {
    if (!item || typeof item !== 'object') return true;
    if (
      systemSubtitleLanguage !== null &&
      typeof item.language === 'string' &&
      item.language.toLowerCase() === systemSubtitleLanguage.toLowerCase()
    ) {
      return { isDefault: true };
    }
    return true;
  },
  Subtitle: { isDefaultOpen: true },
});

Show only SRT subtitles

autoSubtitle: true,
formatAutoSubtitleItem: (item, index) => {
  if (!item || typeof item !== 'object') return false;
  if (String(item.format || '').toLowerCase() !== 'srt') return false;
  return { order: index };
},
Subtitle: { isDefaultOpen: true },

Use the subtitle title as the display name

autoSubtitle: true,
formatAutoSubtitleItem: (item) => {
  if (!item || typeof item !== 'object') return true;
  return item.title || item.language;
},
Subtitle: {},

Remove machine-translated subtitles and sort ASR subtitles first

autoSubtitle: true,
formatAutoSubtitleItem: (item, index) => {
  if (!item || typeof item !== 'object') return true;
  if (item.source === 'MT') return false;
  return { order: item.source === 'ASR' ? 0 : index + 1 };
},
Subtitle: {},

Show only specific languages

autoSubtitle: true,
formatAutoSubtitleItem: (item) => {
  if (!item || typeof item !== 'object') return false;
  const allowedLangs = ['cmn-Hans-CN', 'eng-US'];
  if (!allowedLangs.includes(item.language)) return null;
  return { label: item.title || item.language };
},
Subtitle: {},

Control subtitles with the API

You can control subtitles from your own UI. The subtitle plugin must be registered with Subtitle: {}.

getSubtitleList()

Gets the current subtitle list. Returns [] if the plugin is unavailable or subtitles aren't ready. Master playlist tracks have source: 'hls'.

const list = playerSdkIns.getSubtitleList();
// [
//   { id: 'sub-zh', language: 'cmn-Hans-CN', text: '简体中文', url: 'https://example.com/zh.vtt' },
//   { id: 'sub-en', language: 'eng-US', text: 'English', url: 'https://example.com/en.vtt' },
// ]

Master playlist tracks don't expose playback URLs or internal track indexes. Switch them by id. Their text and label contain the original names, not names formatted by Subtitle.label.

type ISubtitleLabelValue = string | number | Record<string, string | number>;

// Master playlist fields in ISubTitleItem
interface ISubTitleItem {
  source?: 'config' | 'hls';
  id?: string | number;
  language?: string | number;
  text?: ISubtitleLabelValue; // Original subtitle name
  label?: ISubtitleLabelValue; // Compatibility label field
  isDefault?: boolean; // Whether this is the default track
  forced?: boolean; // Whether this is a forced track
  characteristics?: string; // Track characteristics, such as accessibility traits
}

Read the list again after switching episodes. Don't reuse IDs from a previous episode.

switchSubtitle(subtitle)

Switches to a subtitle. Returns a Promise<void>.

async function selectSubtitle(id) {
  try {
    await playerSdkIns.switchSubtitle({ id });
  } catch (error) {
    console.warn('Subtitle switch failed', error);
  }
}

Parameter

Type

Description

subtitle.id

string or number

The subtitle ID. Required if language isn't provided.

subtitle.language

string or number

The language tag. Must match exactly one track in the current list.

An exact id match takes precedence. In hls.js mode, the promise resolves after the engine confirms the switch and rejects if the switch fails.

showSubtitle()

Shows subtitles. Restores the last selected subtitle, or selects the first one if none was selected.

playerSdkIns.showSubtitle();

hideSubtitle()

Hides subtitles. The subtitle list is kept, so you can show it again with showSubtitle() or switchSubtitle().

playerSdkIns.hideSubtitle();

Example: Custom English subtitle button

async function selectEnglishSubtitle() {
  const list = playerSdkIns.getSubtitleList();
  const target = list.find((item) =>
    ['eng-us', 'en-us', 'en'].includes(String(item.language).toLowerCase())
  );
  if (!target || target.id == null) return;

  try {
    await playerSdkIns.switchSubtitle({ id: target.id });
  } catch (error) {
    console.warn('Subtitle switch failed. Refresh the subtitle list.', error);
  }
}

Subtitle events

The following events report subtitle list and selection changes for Master playlists and native HLS. Register them with playerSdkIns.on(VePlayer.Events.EVENT_NAME, callback), and check playbackSessionId before you use the payload.

Event

Payload

Description

HLS_SUBTITLE_TRACKS_UPDATED

IHlsSubtitleTracksUpdatedEvent

The subtitle list was updated.

HLS_SUBTITLE_TRACK_SWITCHING

IHlsSubtitleTrackSwitchEvent

A subtitle switch was submitted.

HLS_SUBTITLE_TRACK_SWITCHED

IHlsSubtitleTrackSwitchEvent

A subtitle switch was confirmed.

interface IHlsSubtitleTracksUpdatedEvent {
  playbackSessionId: string;
  playbackEngine: HlsPlaybackEngine;
  tracks: ReadonlyArray<ISubTitleItem>;
}

interface IHlsSubtitleTrackSwitchEvent {
  playbackSessionId: string;
  playbackEngine: HlsPlaybackEngine;
  from: string | number | null; // Subtitle ID. null means subtitles were off.
  to: string | number | null;
  track?: ISubTitleItem;
}

Customize subtitle labels

Subtitle.label sets the menu labels for every subtitle source. Keys must match the language tags that getSubtitleList() returns. For example, eng-US and en-US are different keys, and en doesn't match eng-US.

Subtitle: {
  isDefaultOpen: true,
  isShowIcon: true,
  label: {
    map: {
      language: {
        'cmn-Hans-CN': { text: '简体中文' },
        'cmn-Hant-CN': { text: '繁體中文' },
        'eng-US': { text: 'English' },
        'zh-CN': { text: '简体中文' },
        en: { text: 'English' },
        'pt-BR': { text: 'Português (Brasil)' },
      },
    },
    formatter: ({ defaultLabel, item }) =>
      item.forced ? `${defaultLabel} (Forced)` : defaultLabel,
  },
},

The map also accepts id and original text keys. The player matches in this order: id, full language tag, base language, then original name. For example, en-US falls back to en. formatter is synchronous and returns the final label.

Labels change only the VePlayer menu. They don't change subtitle content, the subtitle language, or the iOS system subtitle menu. To filter, sort, or select default tracks, use formatAutoSubtitleItem instead.

Localize subtitle labels

To translate labels into the player's UI language, set textKey to a key in the player's languages dictionary. text is the fallback when no translation exists.

lang: 'zh',
languages: {
  zh: { SUBTITLE_EN: '英语' },
  en: { SUBTITLE_EN: 'English' },
},
Subtitle: {
  label: {
    map: {
      language: {
        en: { textKey: 'SUBTITLE_EN', text: 'English' },
        'eng-US': { textKey: 'SUBTITLE_EN', text: 'English' },
      },
    },
  },
},

Troubleshooting

Subtitles don't appear

This happens when the subtitle plugin isn't registered, the list is empty, or subtitles are hidden.

To resolve this, confirm that you set Subtitle, then check whether getSubtitleList() returns items for the current episode. If the list is empty, check the subtitle's link to the video, the Master playlist declarations, and your formatAutoSubtitleItem filters. If the list has items, check whether subtitles are hidden, whether a cue covers the current playback time, and whether the subtitle request succeeded.

Custom labels don't apply

This happens when the label keys don't match the subtitle IDs or language tags, or when the labels are confused with the player UI language.

To resolve this, use the exact id or language values that getSubtitleList() returns. Labels affect only the VePlayer menu, not the iOS system menu.

Next steps

TikTok for Developers