TikTok for Developers

Developer Docs

Last updated November 24, 2026

Integrate Mini Drama Player

Mini Drama Player is the required video player for mini drama mini apps. It's based on the BytePlus Web Player SDK (VePlayer) and enforces platform playback control, so episodes play only after they pass review and are published. This guide covers how to create a player, play and switch episodes, and respond to player events.

Important: After you submit mini drama content for review, you must play it with Mini Drama Player. Third-party players and native HTML video aren't allowed. See Migrate from a third-party player.

Prerequisites

  • You have connected a BytePlus account and uploaded episodes with the Media Asset API.
  • Your mini app initializes the TikTok Minis SDK with TTMinis.init().
  • You can run your mini app in debug mode. The player retrieves playback information from the TikTok app, so it can't play real episodes in a desktop browser.
  • Your TikTok test account has testing permissions for the mini app and is registered in a supported region. Accounts registered in Europe aren't supported.

Supported formats

The following table lists video format support by platform:

Format

Android

iOS

Notes

MP4 (H.264 + AAC)

Supported

Supported

Best compatibility. Recommended.

MP4 (H.265/HEVC + AAC)

Partial. Depends on hardware decoding.

iOS 11 and later

Support varies widely on Android. See Play H.265 videos.

WebM (VP8 + Vorbis)

Supported

iOS 17.4 and later

N/A

WebM (VP9 + Opus)

Supported

iOS 17.4 and later

N/A

WebM (AV1 + Opus)

Android 10 and later, with hardware support

iOS 17.4 and later

N/A

HLS (M3U8) is supported for playback, with adaptive bitrate, multiple audio tracks, and subtitles declared in the playlist. HLS encryption supports AES-128 only. To prevent screen recording, use the disableCapture capability of the TikTok Minis SDK. For HLS configuration, see Play HLS and Transcoded Videos.

Test your integration

TikTok assigns the playback CDN by the region of the TikTok account. If the account region differs from your network region, or your VPN server region, playback can start slowly and buffer.

  • Use a TikTok account registered outside the US and the EU, and connect to a nearby VPN server, such as one in Japan or Singapore. Developers may need to use a VPN depending on their location.
  • To check the account region, in TikTok go to Profile > Settings and privacy > Account > User information > Account region.
  • Before a large launch, prewarm your videos on the CDN with Create a Mini Drama CDN Preload Task.

Before your own episodes are approved, you can test playback with the following sample episodes:

Field

Values

album_id

7667061213232384021

vid

v25b3bgm0018d9jgcu2tgd62dtifvgc0, v25b3bgm0018d9jgdaqtgd63istgth3g, v18b3bgm0018d9jgdjatgd606dirdp0g

episode_id

7667063938195015688, 7667063938195032072, 7667063938195048456

Step 1: Get the player

After you initialize the TikTok Minis SDK, get and cache the VePlayer constructor. Do this early, such as when the page loads:

let VePlayerCtor: any = null;

TTMinis.getPlayer().then((VePlayer: any) => {
  VePlayerCtor = VePlayer;
});

TTMinis.getPlayer() returns a Promise that resolves to the VePlayer constructor. You must call TTMinis.init() first.

The rest of this guide calls the constructor VePlayer.

Step 2: Prepare playback data

Get the following information for approved episodes from your server:

Field

Required

Description

album_id

Yes

The ID of the mini drama.

episode_id

Yes

The ID of the episode.

vid

Yes

The BytePlus video ID of the episode. If you replace an episode's video and resubmit it, update this value.

play_auth_token

Conditional

Required only in TikTok versions earlier than 44.5.0. A temporary playback token from Get a Mini Drama Playback Token.

To check whether the current TikTok version needs a playback token, call TTMinis.canIUse('getDramaInfo'). To avoid supporting earlier versions, set your mini app's minimum supported library version to 0.5 or later (TikTok 44.9.0 on iOS and Android).

Step 3: Create the player

Add a container element to the playback page, then create the player in it. Each player needs its own container, and the container must have a size set in CSS.

<div id="player-container" style="width: 100%; height: 100%"></div>
const playerSdkIns = new VePlayer({
  id: 'player-container', // The ID of the container element
  vid: videoInfo.vid,
  albumId: videoInfo.album_id,
  episodeId: videoInfo.episode_id,
  lang: 'en', // The player UI language
  defaultDefinition: '720p', // Omit if the video has only one definition
  getVideoByToken: {
    playAuthToken: videoInfo.play_auth_token, // Required only before TikTok 44.5.0
  },
});

In a framework such as React, you can pass the container element in root instead of id:

import { useEffect, useRef } from 'react';

export const PlayerComponent: React.FC<Props> = ({ videoInfo }) => {
  const rootRef = useRef<HTMLDivElement | null>(null);
  const playerSdkRef = useRef<any>(null);

  useEffect(() => {
    const root = rootRef.current;
    if (!root || playerSdkRef.current) {
      return;
    }

    playerSdkRef.current = new VePlayer({
      root,
      vid: videoInfo.vid,
      albumId: videoInfo.album_id,
      episodeId: videoInfo.episode_id,
      getVideoByToken: {
        playAuthToken: videoInfo.play_auth_token,
      },
    });

    return () => {
      playerSdkRef.current?.destroy();
      playerSdkRef.current = null;
    };
  }, []);

  return <div ref={rootRef} className="player-container" />;
};

Configure an immersive player UI

Mini dramas play full screen, so a minimal UI usually works best. The following configuration hides controls that mini dramas don't need:

const playerSdkIns = new VePlayer({
  id: 'player-container',
  vid: videoInfo.vid,
  albumId: videoInfo.album_id,
  episodeId: videoInfo.episode_id,
  lang: 'en', // UI language: en, zh-cn, or jp
  closeVideoClick: false, // Toggle play and pause when the user taps the video
  closeVideoDblclick: true, // Don't toggle play and pause on double tap
  videoFillMode: 'fillHeight',
  getVideoByToken: {
    playAuthToken: videoInfo.play_auth_token,
    needPoster: true, // Show the cover before playback starts
  },
  ignores: [
    'moreButtonPlugin', // The More button in the upper-right corner
    'enter',
    'fullscreen',
    'volume',
    'play',
    'pip', // Picture in picture
    'replay',
    'playbackrate',
    'sdkDefinitionPlugin', // The definition menu
  ],
  commonStyle: {
    playedColor: '#ffffff', // The played portion of the progress bar
  },
  mobile: {
    gradient: 'none', // No gradient over the video on mobile
  },
  sdkErrorPlugin: {
    isNeedRefreshButton: false,
  },
  start: {
    disableAnimate: true,
    isShowPause: true,
  },
});

For every option, see the BytePlus configuration reference.

Step 4: Control playback

Playback controls belong to the player kernel. VePlayer creates the kernel asynchronously, so read it from the player property after the READY event:

playerSdkIns.on(VePlayer.Events.READY, () => {
  const player = playerSdkIns.player;
  console.log('player kernel', player);
});

Read kernel properties to get playback state:

const currentTime = playerSdkIns.player?.currentTime;
const paused = playerSdkIns.player?.paused;
const ended = playerSdkIns.player?.ended;

Call kernel methods in response to user actions:

document.getElementById('play_btn').addEventListener('click', () => {
  playerSdkIns.player?.play();
});

document.getElementById('pause_btn').addEventListener('click', () => {
  playerSdkIns.player?.pause();
});

For every kernel property and method, see Player kernel.

Switch episodes

To play another episode without destroying the player, call playNext with the new episode's information:

playerSdkIns
  .playNext({
    albumId: nextEpisode.albumId,
    episodeId: nextEpisode.episodeId,
    vid: nextEpisode.vid,
    getVideoByToken: {
      playAuthToken: nextEpisode.playAuthToken,
    },
  })
  .then(() => {
    console.log('Next episode loaded');
  });

Step 5: Listen for player events

Listen for player events to drive your application logic.

Listen for VePlayer.Events.PLAY to detect when playback starts:

playerSdkIns.on(VePlayer.Events.PLAY, () => {
  console.log('Playback started');
});

Listen for VePlayer.Events.TIME_UPDATE to track the playback position:

playerSdkIns.on(VePlayer.Events.TIME_UPDATE, ({ currentTime }) => {
  console.log('currentTime:', currentTime);
});

Listen for VePlayer.Events.ERROR as soon as you create the player, and before each playNext call, so you capture errors that occur while the player retrieves episode information. For error fields, error codes, and how to measure your playback failure rate, see Mini Drama Player Error Codes and Troubleshooting.

playerSdkIns.on(VePlayer.Events.ERROR, (error) => {
  if (!error) return;
  // Use veErrorCode to classify the error
  console.warn('Playback error', error.veErrorCode, error.veErrorMessage);
});

Get video information

To receive the video information the player retrieves, such as the vid, duration, cover, and candidate streams, pass onGetMediaInfo when you create the player:

const playerSdkIns = new VePlayer({
  id: 'player-container',
  vid: videoInfo.vid,
  albumId: videoInfo.album_id,
  episodeId: videoInfo.episode_id,
  onGetMediaInfo: ({ data, fromCache }) => {
    const streams = (data.playList ?? []).map((stream) => ({
      definition: stream.definition,
      codec: stream.codec,
      streamType: stream.streamType,
      bitrate: stream.bitrate,
    }));

    console.log('media info', {
      vid: data.vid,
      duration: data.duration,
      type: data.type,
      fromCache,
      streams,
    });
  },
});

The callback receives the following fields:

Field

Type

Description

data

object

The video information.

data.vid

string

The video ID.

data.duration

number

The video duration, in the unit returned by the media service.

data.poster

string

The URL of the cover image.

data.type

string

The media type or container format returned by the server.

data.playList

Stream[]

The candidate streams. Common fields include definition, codec, streamType, bitrate, and url.

fromCache

Boolean

true if the information came from the player's media information cache; false if it came from a new request.

Keep the following behavior in mind:

  • The callback can run before READY. Don't access playerSdkIns.player inside it. Wait for READY instead.
  • fromCache describes only the media information. It doesn't mean video data was preloaded.
  • The callback runs again when playNext retrieves new information. Don't treat it as a one-time initialization callback.
  • data.playList lists candidate streams, not the stream that is playing. Don't use playList[0] to determine the current definition or URL.
  • The callback doesn't run if the request fails. Handle failures in the ERROR event.
  • The player catches exceptions thrown in the callback, so they don't block playback. Keep the callback lightweight and handle your own failures.

Step 6: Destroy the player

When you no longer need a player, destroy it to release memory and decoder resources:

playerSdkIns.destroy();

Keep the number of player instances on a page small. You should keep fewer than five, and destroy instances that aren't playing.

Migrate from a third-party player

If you play mini drama content with a third-party player or native HTML video, TikTok replaces the video with a blocked-content UI. To migrate gradually, you can request an exemption through a support ticket or your operations contact.

To customize the UI that replaces a blocked video, call TTMinis.setValidateVideoReplaceElement:

TTMinis.setValidateVideoReplaceElement(
  (videoEl: HTMLVideoElement, replaceReason: string) => HTMLElement | null
);

Return an element to display in place of the video, or null to keep the default UI.

Integration best practices

The same player can deliver very different results depending on the video format and the integration. Playback in mini apps that skip either typically degrades by 50% or more on average compared with the recommended setup.

  • Use a standard playback format. Transcode episodes to MP4 (H.264). See Mini Drama Media Requirements.
  • Load player resources early. Load the TikTok Minis SDK and get the player constructor as soon as the page loads. Load other JavaScript asynchronously so it doesn't delay player creation.
  • Enable preloading. Preloading and media information caching don't take effect automatically. See Optimize Mini Drama Playback Startup.
  • Show a cover image placeholder. Display the episode cover until the first frame renders, to avoid a blank or black screen.
  • Limit player instances. Destroy players that aren't playing, and keep fewer than five per page to reduce memory and CPU use.

Reference demo

The tiktok-minis-drama-demo project is an end-to-end mini drama mini app that applies these practices:

  • Gets the player with window.TTMinis.getPlayer().
  • Reuses a single player and switches episodes with playNext().
  • Preloads manually on the discovery page, then switches to automatic adjacent-episode preloading on the playback page.
  • Detects MSE and ManagedMediaSource support, and falls back to playback without preloading on older iOS versions.
  • Manages episode-switching state, autoplays the next episode, and recovers from switching failures.
  • Handles WebView foreground and background lifecycle events.
  • Optimizes the first frame, caches media information, and reports preload hits.

The plugins/minis-player/ module doesn't depend on the React UI, so you can copy it into an existing TypeScript H5 mini app. You can also fork the whole demo as a starting point.

Player reference

Mini Drama Player supports the BytePlus Web Player SDK APIs, listed below. You don't need to configure a license in TikTok Minis.

Next steps

TikTok for Developers