@@ -15,29 +15,104 @@ import "@videojs/themes/dist/sea/index.css";
1515import videojs , { ReadyCallback } from "video.js" ;
1616import "./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