Skip to content

Commit b1c355e

Browse files
committed
feat: add config prop support
1 parent cc887ee commit b1c355e

File tree

7 files changed

+221
-174
lines changed

7 files changed

+221
-174
lines changed

examples/react/src/App.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,14 @@ class App extends Component {
202202
playbackRate={playbackRate}
203203
volume={volume}
204204
muted={muted}
205+
config={{
206+
youtube: {
207+
color: 'white'
208+
},
209+
vimeo: {
210+
color: 'ffffff'
211+
}
212+
}}
205213
onLoadStart={() => console.log('onLoadStart')}
206214
onReady={() => console.log('onReady')}
207215
onStart={(e) => console.log('onStart', e)}

package-lock.json

Lines changed: 189 additions & 155 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,14 @@
5050
"react-dom": "^17.0.2 || ^18"
5151
},
5252
"dependencies": {
53-
"@mux/mux-player-react": "^2.7.0",
54-
"cloudflare-video-element": "^1.1.6",
55-
"dash-video-element": "^0.0.11",
53+
"@mux/mux-player-react": "^3.3.1",
54+
"cloudflare-video-element": "^1.3.1",
55+
"dash-video-element": "^0.1.1",
5656
"deepmerge": "^4.0.0",
57-
"hls-video-element": "^1.2.7",
58-
"vimeo-video-element": "^1.1.6",
59-
"wistia-video-element": "^1.1.7",
60-
"youtube-video-element": "^1.1.6"
57+
"hls-video-element": "^1.5.0",
58+
"vimeo-video-element": "^1.4.1",
59+
"wistia-video-element": "^1.3.1",
60+
"youtube-video-element": "^1.5.1"
6161
},
6262
"devDependencies": {
6363
"@biomejs/biome": "1.8.2",

src/Player.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ const Player: Player = React.forwardRef((props, ref) => {
9696
muted={props.muted}
9797
autoPlay={props.autoPlay}
9898
loop={props.loop}
99+
config={props.config}
99100
onLoadStart={handleLoadStart}
100101
onPlay={handlePlay}
101102
>

src/ReactPlayer.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ export const createReactPlayer = (players: PlayerEntry[], playerFallback: Player
8484
ref={ref}
8585
activePlayer={player.player ?? (player as unknown as PlayerEntry['player'])}
8686
style={wrapper ? { width: '100%', height: '100%' } : { ...style, width, height }}
87+
config={config}
8788
/>
8889
);
8990
};

src/players.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ const Players: PlayerEntry[] = [
1919
name: 'hls.js',
2020
canPlay: canPlay.hls,
2121
canEnablePIP: () => true,
22-
player: lazy(() => import(/* webpackChunkName: 'reactPlayerHls' */ 'hls-video-element/react')),
22+
player: lazy(
23+
() => import(/* webpackChunkName: 'reactPlayerHls' */ 'hls-video-element/react')
24+
) as React.LazyExoticComponent<React.ComponentType<VideoElementProps>>,
2325
},
2426
{
2527
key: 'dash',
@@ -28,7 +30,7 @@ const Players: PlayerEntry[] = [
2830
canEnablePIP: () => true,
2931
player: lazy(
3032
() => import(/* webpackChunkName: 'reactPlayerDash' */ 'dash-video-element/react')
31-
),
33+
) as React.LazyExoticComponent<React.ComponentType<VideoElementProps>>,
3234
},
3335
{
3436
key: 'mux',
@@ -45,15 +47,15 @@ const Players: PlayerEntry[] = [
4547
canPlay: canPlay.youtube,
4648
player: lazy(
4749
() => import(/* webpackChunkName: 'reactPlayerYouTube' */ 'youtube-video-element/react')
48-
),
50+
) as React.LazyExoticComponent<React.ComponentType<VideoElementProps>>,
4951
},
5052
{
5153
key: 'vimeo',
5254
name: 'Vimeo',
5355
canPlay: canPlay.vimeo,
5456
player: lazy(
5557
() => import(/* webpackChunkName: 'reactPlayerVimeo' */ 'vimeo-video-element/react')
56-
),
58+
) as React.LazyExoticComponent<React.ComponentType<VideoElementProps>>,
5759
},
5860
{
5961
key: 'wistia',
@@ -62,7 +64,7 @@ const Players: PlayerEntry[] = [
6264
canEnablePIP: () => true,
6365
player: lazy(
6466
() => import(/* webpackChunkName: 'reactPlayerWistia' */ 'wistia-video-element/react')
65-
),
67+
) as React.LazyExoticComponent<React.ComponentType<VideoElementProps>>,
6668
},
6769
{
6870
key: 'html',

src/types.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export interface VideoElementProps
1515
extends React.DetailedHTMLProps<VideoHTMLAttributes<HTMLVideoElement>, HTMLVideoElement> {
1616
playbackRate?: number;
1717
volume?: number;
18+
config?: Config;
1819
}
1920

2021
export interface ReactPlayerProps extends PreviewProps, VideoElementProps {
@@ -38,11 +39,11 @@ export interface PreviewProps {
3839
}
3940

4041
export interface Config {
41-
html: Record<string, unknown>;
42-
hls: Record<string, unknown>;
43-
dash: Record<string, unknown>;
44-
mux: Record<string, unknown>;
45-
youtube: Record<string, unknown>;
46-
vimeo: Record<string, unknown>;
47-
wistia: Record<string, unknown>;
42+
html?: Record<string, unknown>;
43+
hls?: Record<string, unknown>;
44+
dash?: Record<string, unknown>;
45+
mux?: Record<string, unknown>;
46+
youtube?: Record<string, unknown>;
47+
vimeo?: Record<string, unknown>;
48+
wistia?: Record<string, unknown>;
4849
}

0 commit comments

Comments
 (0)