Skip to content

Commit 545c2a2

Browse files
committed
Update VideoPlayer component props and styles
1 parent 7b494ee commit 545c2a2

File tree

3 files changed

+86
-5
lines changed

3 files changed

+86
-5
lines changed

.npmignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
stories
2-
example
2+
example
3+
.storybook
4+
.github
5+
src

example/src/App.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ const App = () => {
1414
theme: "forest", // 'city', 'fantasy', 'forest', 'sea'
1515
autoPlay: false,
1616
loop: false,
17+
width: 1080,
18+
height: 720,
1719
sources: videoSources,
1820
controlBar: {
1921
skipButtons: {
@@ -28,7 +30,7 @@ const App = () => {
2830
},
2931
};
3032

31-
return <VideoPlayer {...videoProps} />;
33+
return <VideoPlayer {...videoProps} className="name" />;
3234
};
3335

3436
export default App;

src/VideoPlayer.tsx

Lines changed: 79 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,29 +15,104 @@ import "@videojs/themes/dist/sea/index.css";
1515
import videojs, { ReadyCallback } from "video.js";
1616
import "./VideoPlayer.css";
1717

18-
export interface VideoPlayerProps {
18+
export interface VideoPlayerProps extends React.HTMLAttributes<HTMLDivElement> {
19+
/**
20+
* The theme of the video player
21+
* @default "city"
22+
*/
1923
theme?: "city" | "fantasy" | "forest" | "sea";
24+
25+
/**
26+
* The height and width of the video player
27+
* @default 1080
28+
*/
2029
height?: number;
30+
31+
/**
32+
* The height and width of the video player
33+
* @default 1920
34+
*/
2135
width?: number;
36+
37+
/**
38+
* Whether the video should autoplay or not
39+
* @default false
40+
*/
2241
autoPlay?: boolean;
42+
43+
/**
44+
* Whether the video should loop or not
45+
* @default false
46+
*/
2347
loop?: boolean;
48+
49+
/**
50+
* The sources of the video
51+
* @default []
52+
* @example
53+
* ```tsx
54+
* <VideoPlayer
55+
* sources={[
56+
* {
57+
* src: "https://vjs.zencdn.net/v/oceans.mp4",
58+
* type: "video/mp4",
59+
* },
60+
* {
61+
* src: "https://vjs.zencdn.net/v/oceans.webm",
62+
* type: "video/webm",
63+
* },
64+
* {
65+
* src: "https://vjs.zencdn.net/v/oceans.ogv",
66+
* type: "video/ogg",
67+
* },
68+
* ]}
69+
* />
70+
*/
2471
sources?: {
2572
src: string;
2673
type: string;
2774
}[];
75+
76+
/**
77+
* The poster of the video
78+
* @default ""
79+
*/
2880
poster?: string;
2981

30-
// Videojs specific props
82+
// -------------- Videojs specific props
83+
84+
/**
85+
* Whether the video should be fluid or not
86+
*/
3187
controlBar?: {
3288
skipButtons?: {
3389
forward?: number;
3490
backward?: number;
3591
};
3692
};
93+
94+
/**
95+
* The playback rates of the video
96+
* @default [0.5, 1, 1.5, 2]
97+
*/
3798
playbackRates?: number[];
99+
100+
/**
101+
* Whether the video should be fluid or not
102+
* @default false
103+
*/
38104
disablePictureInPicture?: boolean;
105+
106+
/**
107+
* Whether the video should be fluid or not
108+
* @default false
109+
*/
39110
isFluid?: boolean;
40111

112+
/**
113+
* Callback when the video is ready
114+
* @default undefined
115+
*/
41116
onReady?: (ready: ReadyCallback | undefined) => void;
42117
}
43118

@@ -60,6 +135,7 @@ const VideoPlayer: React.FC<VideoPlayerProps> = ({
60135
playbackRates = [0.5, 1, 1.5, 2],
61136
disablePictureInPicture = false,
62137
onReady,
138+
...props
63139
}) => {
64140
const videoRef = React.useRef(null);
65141

@@ -83,7 +159,7 @@ const VideoPlayer: React.FC<VideoPlayerProps> = ({
83159

84160
return (
85161
<div>
86-
<div className="gl-video-player__wrapper">
162+
<div className="gl-video-player__wrapper" {...props}>
87163
<video
88164
ref={videoRef}
89165
className={`video-js vjs-theme-${theme} gl-video-player__video ${

0 commit comments

Comments
 (0)