Skip to content
FrameworkStyle

tiktok-video

Video component that plays TikTok videos through the TikTok embed player

The TikTok embed player expects portrait video and won’t draw its chrome below 325×578, so the element starts at that size rather than the usual 300×150.

Import

pnpm add @videojs/html @videojs/tiktok-video
import '@videojs/html/media/tiktok-video';

Or load it from the CDN:

<script type="module" src="https://cdn.jsdelivr.net/npm/@videojs/cdn@10.0.0-beta.32/media/tiktok-video.js"></script>

Load a source

src takes a TikTok video URL or a raw numeric video id. The @user/video/<id> URLs the app hands out, share/video/<id> links, and player/v1/<id> embed URLs all work.

<tiktok-video src="https://www.tiktok.com/@_luwes/video/7527476667770522893"></tiktok-video>

Controls

TikTok always draws part of its own chrome: the center play button, author header, and social rail are always visible. controls adds the progress bar and control buttons on top of those. Without controls, the element ignores pointer events, so a player skin above it receives every click.

Deferred startup

TikTok builds its player lazily: until something starts playback, the embed has no video element, reports a duration of 0, and silently drops commands. The element works around this by starting a muted autoplay and pausing it immediately, so the embed answers play, pause, and seek before the first play.

Two settings opt out. preload="none" skips the warm-up, leaving the network untouched until the viewer presses play, and the controls inert until then. controls hands playback to TikTok’s own chrome instead.

Behavior

  • Mute works, but there’s no volume control: the embed reports a level but takes no command to set one.
  • No playback rate and no text tracks; captions are toggled with engine.tiktok.closed_caption.
  • poster and playsInline never reach the embed: it always plays inline and draws the video’s own cover image.
  • Changing controls or loop after the embed is up rebuilds it; rewriting the iframe URL is the only reload TikTok allows.

Examples

Basic Usage

<tiktok-video class="tiktok-video" src="https://www.tiktok.com/@_luwes/video/7527476667770522893" controls></tiktok-video>

API Reference

Attributes

These attributes configure the embedded media adapter:

AttributeTypeDefaultDetails
autoplaybooleanfalse
controlsbooleanfalse
loopbooleanfalse
mutedbooleanfalse
playsinlinebooleantrue
posterstring''
preloadMediaPreloadType'metadata'
srcstring''

Properties

PropertyTypeDefaultDetails
autoplaybooleanfalse
bufferedTimeRangeLike
controlsbooleanfalse
currentSrcstring
currentTimenumber
defaultMutedbooleanfalse
durationnumber
endedboolean
engineWindow | null
errorMediaError | null
isFullscreenboolean
loopbooleanfalse
mutedbooleanfalse
pausedboolean
played{ length: number; start(index: number): number; end(index: number): number }
playsInlinebooleantrue
posterstring''
preloadMediaPreloadType'metadata'
readyStatenumber
seekableTimeRangeLike
seekingboolean
source{ src?: string; engine?: TikTokSourceEngineConfig } | nullnull
srcstring''
textTracksTextTrackListLike

Engine options

source.engine.tiktok

Pass TikTok player parameters under source.engine.tiktok, spelled exactly as TikTok spells them, each one 0 or 1, plus anything TikTok adds next. Media Sources covers how engine options fit into a structured source.

autoplay, controls, loop, and muted come from the props of the same name, so they have no engine.tiktok spelling.

const video = document.querySelector('tiktok-video');
video.source = {
  src: 'https://www.tiktok.com/@_luwes/video/7527476667770522893',
  engine: { tiktok: { closed_caption: 0, rel: 1 } },
};
OptionTypeDetails
closed_caption0 | 1 | undefined
description0 | 1 | undefined
fullscreen_button0 | 1 | undefined
music_info0 | 1 | undefined
native_context_menu0 | 1 | undefined
play_button0 | 1 | undefined
progress_bar0 | 1 | undefined
referrerPolicyReferrerPolicy | undefined
rel0 | 1 | undefined
timestamp0 | 1 | undefined
volume_control0 | 1 | undefined

Methods

Supports these media methods: afterLoadbeginLoadcreatePlayerexitFullscreenisStalelistenloadonCurrentTimeonErroronLoadedonMessageonPlayerErroronStateChangeparkpauseplaypostrequestFullscreenresetStatesettleSeeksnapshotPropstakeOver

Events

Implements these standard media events through the embedded player: durationchangeemptiedendederrorloadedmetadataloadstartpauseplayplayingseekedseekingtimeupdatevolumechangewaiting

Also emits these Video.js-specific events:

EventDescription
loadcomplete
sourcechangeFired when `source` changes, either directly or by resolving a new `src`. Read `source` for the new value.