Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions examples/react/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,18 @@ const App = () => {
},
spotify: {
preferVideo: true
},
tiktok: {
fullscreen_button: true,
progress_bar: true,
play_button: true,
volume_control: true,
timestamp: false,
music_info: false,
description: false,
rel: false,
native_context_menu: true,
closed_caption: false,
}
Copy link

Copilot AI Jul 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing comma after the spotify configuration object, which will cause a syntax error when the tiktok configuration is added.

Copilot uses AI. Check for mistakes.
}}
onLoadStart={() => console.log('onLoadStart')}
Expand Down Expand Up @@ -483,6 +495,13 @@ const App = () => {
{renderLoadButton('https://www.twitch.tv/kronovi', 'Test B')}
</td>
</tr>
<tr>
<th>TikTok</th>
<td>
{renderLoadButton('https://www.tiktok.com/@_luwes/video/7527476667770522893', 'Test A')}
{renderLoadButton('https://www.tiktok.com/@scout2015/video/6718335390845095173', 'Test B')}
</td>
</tr>
<tr>
<th>Custom</th>
<td>
Expand Down
23 changes: 15 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@
"deepmerge": "^4.0.0",
"hls-video-element": "^1.5.6",
"spotify-audio-element": "^1.0.2",
"twitch-video-element": "^0.1.1",
"vimeo-video-element": "^1.5.2",
"tiktok-video-element": "^0.1.0",
"twitch-video-element": "^0.1.2",
"vimeo-video-element": "^1.5.3",
"wistia-video-element": "^1.3.3",
"youtube-video-element": "^1.6.1"
},
Expand Down
2 changes: 2 additions & 0 deletions src/patterns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const MATCH_URL_WISTIA =
/(?:wistia\.(?:com|net)|wi\.st)\/(?:medias|embed)\/(?:iframe\/)?([^?]+)/;
export const MATCH_URL_SPOTIFY = /open\.spotify\.com\/(\w+)\/(\w+)/i;
export const MATCH_URL_TWITCH = /(?:www\.|go\.)?twitch\.tv\/([a-zA-Z0-9_]+|(videos?\/|\?video=)\d+)($|\?)/;
export const MATCH_URL_TIKTOK = /tiktok\.com\/(?:@[^/]+\/video\/)?(\d+)(?:\/([\w-]+))?/;
Copy link

Copilot AI Jul 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The TikTok URL regex pattern may not handle all TikTok URL variations. Consider adding support for mobile URLs (m.tiktok.com) and ensuring the pattern matches the actual URL structure used in the test cases.

Suggested change
export const MATCH_URL_TIKTOK = /tiktok\.com\/(?:@[^/]+\/video\/)?(\d+)(?:\/([\w-]+))?/;
export const MATCH_URL_TIKTOK = /(?:www\.|m\.)?tiktok\.com\/(?:@[^/]+\/video\/|v\/)?(\d+)(?:\/([\w-]+))?/;

Copilot uses AI. Check for mistakes.

const canPlayFile = (url: string, test: (u: string) => boolean) => {
if (Array.isArray(url)) {
Expand Down Expand Up @@ -40,4 +41,5 @@ export const canPlay = {
wistia: (url: string) => MATCH_URL_WISTIA.test(url),
spotify: (url: string) => MATCH_URL_SPOTIFY.test(url),
twitch: (url: string) => MATCH_URL_TWITCH.test(url),
tiktok: (url: string) => MATCH_URL_TIKTOK.test(url),
};
9 changes: 9 additions & 0 deletions src/players.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,15 @@ const Players: PlayerEntry[] = [
() => import(/* webpackChunkName: 'reactPlayerTwitch' */ 'twitch-video-element/react')
) as React.LazyExoticComponent<React.ComponentType<VideoElementProps>>,
},
{
key: 'tiktok',
name: 'TikTok',
canPlay: canPlay.tiktok,
canEnablePIP: () => false,
player: lazy(
() => import(/* webpackChunkName: 'reactPlayerTiktok' */ 'tiktok-video-element/react')
) as React.LazyExoticComponent<React.ComponentType<VideoElementProps>>,
},
{
key: 'html',
name: 'html',
Expand Down
2 changes: 2 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type SpotifyAudioElement from 'spotify-audio-element';
import type YouTubeVideoElement from 'youtube-video-element';
import type VimeoVideoElement from 'vimeo-video-element';
import type TwitchVideoElement from 'twitch-video-element';
import type TikTokVideoElement from 'tiktok-video-element';

interface VideoHTMLAttributes<T> extends MediaHTMLAttributes<T> {
height?: number | string | undefined;
Expand Down Expand Up @@ -49,6 +50,7 @@ export interface Config {
html?: Record<string, unknown>;
mux?: Record<string, unknown>;
spotify?: SpotifyAudioElement['config'];
tiktok?: TikTokVideoElement['config'];
twitch?: TwitchVideoElement['config'];
vimeo?: VimeoVideoElement['config'];
wistia?: Record<string, unknown>;
Expand Down