softbuilders-react-video-player 1.1.73 → 1.1.75

Sign up to get free protection for your applications and to get access to all the features.
@@ -26,19 +26,22 @@ const renderBigPlayButton = (id, player, isPaused, setIsPaused, opacity = "100")
26
26
  let controlBarRoot = {};
27
27
  const renderControlBar = (id, player, isPaused, setIsPaused, duration, notes, chapters, seekStep = 5, handleSaveNoteAction, opacity = "0", handleControlDisplayTimer = () => { }, bgColor = "transparent", setIsQualityMenuOpen, setIsSubtitleMenuOpen, disableNote, setNoteOpen, noteButtonClick) => {
28
28
  const container = document.getElementById(`video-container-${id}`);
29
+ console.log("container: ", container);
29
30
  if (container) {
31
+ console.log("container1: ");
30
32
  container.style.height = "100%";
31
33
  container.style.aspectRatio = "16 / 9";
32
34
  const element = container.querySelector(".vjs-control-bar");
33
35
  if (element) {
36
+ console.log("container2: ");
34
37
  if (!controlBarRoot[id]) {
35
38
  controlBarRoot[id] = ReactDOM.createRoot(element);
39
+ element.style.display = "flex";
40
+ element.style.height = "100%";
41
+ element.style.alignItems = "flex-end";
36
42
  }
37
- element.style.display = "flex";
38
43
  element.style.opacity = opacity;
39
44
  element.style.backgroundColor = `${bgColor} !important`;
40
- element.style.height = "100%";
41
- element.style.alignItems = "flex-end";
42
45
  controlBarRoot[id].render(_jsx(SoftBuildersVideoPlayerProvider, { children: _jsx(ControlBar, { id: id, player: player, isPaused: isPaused, setIsPaused: setIsPaused, duration: duration, notes: notes, chapters: chapters, seekStep: seekStep, handleSaveNoteAction: handleSaveNoteAction, handleControlDisplayTimer: handleControlDisplayTimer, setIsSubtitleMenuOpen: setIsSubtitleMenuOpen, setIsQualityMenuOpen: setIsQualityMenuOpen, disableNote: disableNote, setNoteOpen: setNoteOpen, noteButtonClick: noteButtonClick }) }));
43
46
  }
44
47
  }
@@ -54,9 +57,9 @@ const VideoPlayerComponent = forwardRef(({ id, options, notes, chapters, startTi
54
57
  const [bgColor, setBgColor] = useState("transparent");
55
58
  const [isQualityMenuOpen, setIsQualityMenuOpen] = useState(false);
56
59
  const [isSubtitleMenuOpen, setIsSubtitleMenuOpen] = useState(false);
57
- const [isHovered, setIsHovered] = useState(false);
58
60
  const [isNoteOpen, setNoteOpen] = useState(false);
59
61
  const onReady = (player) => {
62
+ console.log("onReady: ", onReady);
60
63
  if (playerRef) {
61
64
  playerRef.current = player;
62
65
  setIsReady(true);
@@ -89,22 +92,6 @@ const VideoPlayerComponent = forwardRef(({ id, options, notes, chapters, startTi
89
92
  onReady(playerRef.current);
90
93
  });
91
94
  }
92
- return () => {
93
- if (playerRef.current) {
94
- playerRef.current.dispose();
95
- playerRef.current = undefined;
96
- setTimeout(() => {
97
- if (bigPlayButtonRoot[id]) {
98
- bigPlayButtonRoot[id].unmount();
99
- bigPlayButtonRoot[id] = undefined;
100
- }
101
- if (controlBarRoot[id]) {
102
- controlBarRoot[id].unmount();
103
- controlBarRoot[id] = undefined;
104
- }
105
- }, 0);
106
- }
107
- };
108
95
  }, [options, poster]); // Added poster to dependency array
109
96
  useEffect(() => {
110
97
  if (playerRef.current && isReady) {
@@ -125,7 +112,7 @@ const VideoPlayerComponent = forwardRef(({ id, options, notes, chapters, startTi
125
112
  renderControlBar(id, playerRef.current, isPaused, setIsPaused, duration, notes, chapters, 5, handleSaveNoteAction, opacity, (e) => {
126
113
  handlePlayerClick(e, true);
127
114
  }, bgColor, setIsQualityMenuOpen, setIsSubtitleMenuOpen, disableNote, setNoteOpen, noteButtonClick);
128
- }, 500);
115
+ }, 0);
129
116
  return () => clearTimeout(controlBarTimeout);
130
117
  }
131
118
  }, [
@@ -157,6 +144,14 @@ const VideoPlayerComponent = forwardRef(({ id, options, notes, chapters, startTi
157
144
  return () => clearInterval(intervalId);
158
145
  }
159
146
  }, []);
147
+ useEffect(() => {
148
+ var _a, _b;
149
+ if (playerRef.current) {
150
+ (_a = playerRef.current) === null || _a === void 0 ? void 0 : _a.currentTime(startTime);
151
+ console.log("startTimenotes: ", startTime);
152
+ (_b = playerRef.current) === null || _b === void 0 ? void 0 : _b.play();
153
+ }
154
+ }, [startTime]);
160
155
  useEffect(() => {
161
156
  return () => {
162
157
  if (playerRef.current) {
@@ -197,23 +192,12 @@ const VideoPlayerComponent = forwardRef(({ id, options, notes, chapters, startTi
197
192
  }
198
193
  }, [isQualityMenuOpen, isSubtitleMenuOpen]);
199
194
  useEffect(() => {
200
- console.log("isNoteOpen: ", isNoteOpen);
201
- if (isNoteOpen) {
202
- if (timeoutRef.current) {
203
- clearTimeout(timeoutRef.current);
204
- }
205
- }
206
- else {
207
- if (timeoutRef.current) {
208
- clearTimeout(timeoutRef.current);
209
- }
210
- timeoutRef.current = setTimeout(() => {
211
- setIsControlBarPresent(false);
212
- }, 3000);
195
+ if (playerRef.current) {
213
196
  }
214
- }, [isNoteOpen]);
197
+ }, [notes]);
215
198
  const handlePlayerClick = async (e, isTimerOnly = false) => {
216
199
  e.preventDefault();
200
+ console.log("handlePlayerClick: ", isTimerOnly);
217
201
  if (timeoutRef.current) {
218
202
  clearTimeout(timeoutRef.current);
219
203
  }
@@ -283,9 +267,8 @@ const VideoPlayerComponent = forwardRef(({ id, options, notes, chapters, startTi
283
267
  const [timeSeeker, setTimeSeeker] = useState("0");
284
268
  useEffect(() => {
285
269
  const updateTimeSeeker = () => {
286
- var _a;
287
- if (playerRef === null || playerRef === void 0 ? void 0 : playerRef.current) {
288
- const currentTime = (_a = playerRef.current) === null || _a === void 0 ? void 0 : _a.currentTime();
270
+ if (playerRef.current) {
271
+ const currentTime = playerRef.current.currentTime();
289
272
  const duration = playerRef.current.duration();
290
273
  if (duration && currentTime !== undefined) {
291
274
  setTimeSeeker(`${(currentTime / duration) * 100}%`);
@@ -295,13 +278,12 @@ const VideoPlayerComponent = forwardRef(({ id, options, notes, chapters, startTi
295
278
  }
296
279
  }
297
280
  };
298
- // Set up an interval to update the seeker
299
281
  const interval = setInterval(updateTimeSeeker, 500); // Update every 500ms
300
282
  return () => clearInterval(interval); // Cleanup interval on unmount
301
283
  }, [playerRef]);
302
- return (_jsxs("div", { ref: videoRefs, id: `video-container-${id}`, onMouseMove: () => {
303
- !isNoteOpen ? handlePlayerClick(event, true) : "";
304
- }, className: "sb-relative sb-rounded-md sb-overflow-hidden sb-w-full sb-h-full sb-bottom-2 ", onMouseEnter: () => setIsHovered(true), onMouseLeave: () => setIsHovered(false), children: [bottomRedBar && (_jsx("div", { ref: childRef, onClick: handlePlayerClick, className: `sb-h-[3px] sb-transition-opacity sb-duration-500 sb-delay-400 sb-z-10 ease-in-out sb-border-spacing-x-2 sb-absolute sb-bg-[red] sb-bottom-0 ${opacity == "100" ? "sb-opacity-0" : "sb-opacity-100"}`, style: {
284
+ return (_jsxs("div", { ref: videoRefs, id: `video-container-${id}`, onMouseMove: (e) => {
285
+ handlePlayerClick(e, true);
286
+ }, className: "sb-relative sb-rounded-md sb-overflow-hidden sb-w-full sb-h-full sb-bottom-2 ", children: [bottomRedBar && (_jsx("div", { ref: childRef, onClick: handlePlayerClick, className: `sb-h-[3px] sb-transition-opacity sb-duration-500 sb-delay-400 sb-z-10 ease-in-out sb-border-spacing-x-2 sb-absolute sb-bg-[red] sb-bottom-0 ${opacity == "100" ? "sb-opacity-0" : "sb-opacity-100"}`, style: {
305
287
  width: timeSeeker,
306
288
  } })), _jsx("div", { className: "hover:sb-cursor-pointer sb-w-full sb-h-full", "data-vjs-player": true, children: _jsx("div", { onClick: handlePlayerClick, ref: videoRef, className: "sb-h-full sb-w-full sb-relative" }) })] }));
307
289
  });
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/VideoPlayerComponent/index.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACvE,OAAO,QAAQ,MAAM,kBAAkB,CAAC;AACxC,OAAO,OAAO,MAAM,UAAU,CAAC;AAE/B,OAAO,4BAA4B,CAAC;AACpC,OAAO,UAAU,MAAM,eAAe,CAAC;AAMvC,OAAO,mBAAmB,CAAC;A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AAE,CAAC;gBAE9C,IAAI,QAAQ,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;oBAC1C,aAAa,CAAC,GAAG,CAAC,WAAW,GAAG,QAAQ,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC;gBACtD,CAAC;qBAAM,CAAC;oBACN,aAAa,CAAC,GAAG,CAAC,CAAC;gBACrB,CAAC;YACH,CAAC;QACH,CAAC,CAAC;QAEF,MAAM,QAAQ,GAAG,WAAW,CAAC,gBAAgB,EAAE,GAAG,CAAC,CAAC,CAAC,qBAAqB;QAE1E,OAAO,GAAG,EAAE,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC,8BAA8B;IACtE,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;IAEhB,OAAO,CACL,eACE,GAAG,EAAE,SAAS,EACd,EAAE,EAAE,mBAAmB,EAAE,EAAE,EAC3B,WAAW,EAAE,CAAC,CAAC,EAAE,EAAE;YACjB,iBAAiB,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;QAC7B,CAAC,EACD,SAAS,EAAC,gFAAgF,aAEzF,YAAY,IAAI,CACf,cACE,GAAG,EAAE,QAAQ,EACb,OAAO,EAAE,iBAAiB,EAC1B,SAAS,EAAE,+IACT,OAAO,IAAI,KAAK,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,gBACtC,EAAE,EACF,KAAK,EAAE;oBACL,KAAK,EAAE,UAAU;iBAClB,GACI,CACR,EACD,cACE,SAAS,EAAC,6CAA6C,qCAIvD,cACE,OAAO,EAAE,iBAAiB,EAC1B,GAAG,EAAE,QAAQ,EACb,SAAS,EAAC,iCAAiC,GACtC,GACH,IACF,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AACF,eAAe,oBAAoB,CAAC"}
@@ -14,6 +14,7 @@ import "../../styles/tailwind.css";
14
14
  import { SoftBuildersVideoPlayerProvider } from "./provider";
15
15
  import BigPlayButton from "../BigPlayButton";
16
16
  import { flushSync } from "react-dom";
17
+ import { use } from "video.js/dist/types/tech/middleware";
17
18
  let bigPlayButtonRoot: {
18
19
  [key: string]: ReactDOM.Root | undefined;
19
20
  } = {};
@@ -68,19 +69,27 @@ const renderControlBar = <T,>(
68
69
  noteButtonClick?: (e: any) => void
69
70
  ) => {
70
71
  const container = document.getElementById(`video-container-${id}`);
72
+ console.log("container: ", container);
73
+
71
74
  if (container) {
75
+ console.log("container1: ");
76
+
72
77
  container.style.height = "100%";
73
78
  container.style.aspectRatio = "16 / 9";
74
79
  const element: any = container.querySelector(".vjs-control-bar");
75
80
  if (element) {
81
+ console.log("container2: ");
82
+
76
83
  if (!controlBarRoot[id]) {
77
84
  controlBarRoot[id] = ReactDOM.createRoot(element as HTMLElement);
85
+ element.style.display = "flex";
86
+ element.style.height = "100%";
87
+ element.style.alignItems = "flex-end";
78
88
  }
79
- element.style.display = "flex";
89
+
80
90
  element.style.opacity = opacity;
81
91
  element.style.backgroundColor = `${bgColor} !important`;
82
- element.style.height = "100%";
83
- element.style.alignItems = "flex-end";
92
+
84
93
  controlBarRoot[id].render(
85
94
  <SoftBuildersVideoPlayerProvider>
86
95
  <ControlBar
@@ -149,13 +158,14 @@ const VideoPlayerComponent = forwardRef<HTMLDivElement, Props<any>>(
149
158
  const [bgColor, setBgColor] = useState("transparent");
150
159
  const [isQualityMenuOpen, setIsQualityMenuOpen] = useState(false);
151
160
  const [isSubtitleMenuOpen, setIsSubtitleMenuOpen] = useState(false);
152
- const [isHovered, setIsHovered] = useState(false);
153
161
  const [isNoteOpen, setNoteOpen] = useState(false);
154
162
  const onReady = (player: Player) => {
163
+ console.log("onReady: ", onReady);
155
164
  if (playerRef) {
156
165
  playerRef.current = player;
157
166
  setIsReady(true);
158
167
  player?.currentTime(startTime);
168
+
159
169
  player.on("waiting", () => {});
160
170
  player.on("dispose", () => {
161
171
  videojs.log("player will dispose");
@@ -186,22 +196,6 @@ const VideoPlayerComponent = forwardRef<HTMLDivElement, Props<any>>(
186
196
  onReady(playerRef.current as Player);
187
197
  });
188
198
  }
189
- return () => {
190
- if (playerRef.current) {
191
- playerRef.current.dispose();
192
- playerRef.current = undefined;
193
- setTimeout(() => {
194
- if (bigPlayButtonRoot[id]) {
195
- bigPlayButtonRoot[id].unmount();
196
- bigPlayButtonRoot[id] = undefined;
197
- }
198
- if (controlBarRoot[id]) {
199
- controlBarRoot[id].unmount();
200
- controlBarRoot[id] = undefined;
201
- }
202
- }, 0);
203
- }
204
- };
205
199
  }, [options, poster]); // Added poster to dependency array
206
200
  useEffect(() => {
207
201
  if (playerRef.current && isReady) {
@@ -238,7 +232,7 @@ const VideoPlayerComponent = forwardRef<HTMLDivElement, Props<any>>(
238
232
  setNoteOpen,
239
233
  noteButtonClick
240
234
  );
241
- }, 500);
235
+ }, 0);
242
236
  return () => clearTimeout(controlBarTimeout);
243
237
  }
244
238
  }, [
@@ -275,6 +269,13 @@ const VideoPlayerComponent = forwardRef<HTMLDivElement, Props<any>>(
275
269
  return () => clearInterval(intervalId);
276
270
  }
277
271
  }, []);
272
+ useEffect(() => {
273
+ if (playerRef.current) {
274
+ playerRef.current?.currentTime(startTime);
275
+ console.log("startTimenotes: ", startTime);
276
+ playerRef.current?.play();
277
+ }
278
+ }, [startTime]);
278
279
  useEffect(() => {
279
280
  return () => {
280
281
  if (playerRef.current) {
@@ -314,26 +315,16 @@ const VideoPlayerComponent = forwardRef<HTMLDivElement, Props<any>>(
314
315
  }, 3000);
315
316
  }
316
317
  }, [isQualityMenuOpen, isSubtitleMenuOpen]);
317
- useEffect(() => {
318
- console.log("isNoteOpen: ", isNoteOpen);
319
-
320
- if (isNoteOpen) {
321
- if (timeoutRef.current) {
322
- clearTimeout(timeoutRef.current);
323
- }
324
- } else {
325
- if (timeoutRef.current) {
326
- clearTimeout(timeoutRef.current);
327
- }
328
318
 
329
- timeoutRef.current = setTimeout(() => {
330
- setIsControlBarPresent(false);
331
- }, 3000);
319
+ useEffect(() => {
320
+ if (playerRef.current) {
332
321
  }
333
- }, [isNoteOpen]);
322
+ }, [notes]);
334
323
 
335
324
  const handlePlayerClick = async (e: any, isTimerOnly = false) => {
336
325
  e.preventDefault();
326
+ console.log("handlePlayerClick: ", isTimerOnly);
327
+
337
328
  if (timeoutRef.current) {
338
329
  clearTimeout(timeoutRef.current);
339
330
  }
@@ -406,8 +397,8 @@ const VideoPlayerComponent = forwardRef<HTMLDivElement, Props<any>>(
406
397
 
407
398
  useEffect(() => {
408
399
  const updateTimeSeeker = () => {
409
- if (playerRef?.current) {
410
- const currentTime = playerRef.current?.currentTime();
400
+ if (playerRef.current) {
401
+ const currentTime = playerRef.current.currentTime();
411
402
  const duration = playerRef.current.duration();
412
403
 
413
404
  if (duration && currentTime !== undefined) {
@@ -418,7 +409,6 @@ const VideoPlayerComponent = forwardRef<HTMLDivElement, Props<any>>(
418
409
  }
419
410
  };
420
411
 
421
- // Set up an interval to update the seeker
422
412
  const interval = setInterval(updateTimeSeeker, 500); // Update every 500ms
423
413
 
424
414
  return () => clearInterval(interval); // Cleanup interval on unmount
@@ -428,12 +418,10 @@ const VideoPlayerComponent = forwardRef<HTMLDivElement, Props<any>>(
428
418
  <div
429
419
  ref={videoRefs}
430
420
  id={`video-container-${id}`}
431
- onMouseMove={() => {
432
- !isNoteOpen ? handlePlayerClick(event, true) : "";
421
+ onMouseMove={(e) => {
422
+ handlePlayerClick(e, true);
433
423
  }}
434
424
  className="sb-relative sb-rounded-md sb-overflow-hidden sb-w-full sb-h-full sb-bottom-2 "
435
- onMouseEnter={() => setIsHovered(true)}
436
- onMouseLeave={() => setIsHovered(false)}
437
425
  >
438
426
  {bottomRedBar && (
439
427
  <div
@@ -1,82 +1,82 @@
1
- import React, {
2
- createContext,
3
- useContext,
4
- useState,
5
- ReactNode,
6
- useEffect,
7
- } from "react";
8
- import Player from "video.js/dist/types/player";
9
-
10
- interface SoftBuildersVideoPlayerContextType {
11
- player: Player | undefined;
12
- setPlayer: React.Dispatch<React.SetStateAction<Player | undefined>>;
13
-
14
- currentTime: number;
15
- setCurrentTime: (value: number) => void;
16
-
17
- duration: number;
18
- setDuration: React.Dispatch<React.SetStateAction<number>>;
19
-
20
- // isPaused: boolean;
21
- // setIsPaused: React.Dispatch<React.SetStateAction<boolean>>;
22
-
23
- downloadedBufferPercentage: number;
24
- downloadedBufferTime: number;
25
- setDownloadedBufferTimeufferTime: React.Dispatch<
26
- React.SetStateAction<number>
27
- >;
28
- }
29
-
30
- const SoftBuildersVideoPlayerContext = createContext<
31
- SoftBuildersVideoPlayerContextType | undefined
32
- >(undefined);
33
-
34
- // Create a provider component
35
- export const SoftBuildersVideoPlayerProvider = ({
36
- children,
37
- }: {
38
- children: ReactNode;
39
- }) => {
40
- const [player, setPlayer] = useState<Player | undefined>(undefined);
41
- const [currentTime, setCurrentTime] = useState<number>(0);
42
- const [duration, setDuration] = useState<number>(1);
43
- // const [isPaused, setIsPaused] = useState(false);
44
- const [downloadedBufferTime, setDownloadedBufferTimeufferTime] = useState(0);
45
- const [downloadedBufferPercentage, setDownloadedBufferPercentage] =
46
- useState(0);
47
-
48
- useEffect(() => {
49
- setDownloadedBufferPercentage((downloadedBufferTime * 100) / duration);
50
- }, [downloadedBufferTime]);
51
-
52
- return (
53
- <SoftBuildersVideoPlayerContext.Provider
54
- value={{
55
- player,
56
- setPlayer,
57
- duration,
58
- setDuration,
59
- currentTime,
60
- setCurrentTime: (value) => setCurrentTime(Math.floor(value)),
61
- // isPaused,
62
- // setIsPaused,
63
- downloadedBufferTime,
64
- setDownloadedBufferTimeufferTime,
65
- downloadedBufferPercentage,
66
- }}
67
- >
68
- {children}
69
- </SoftBuildersVideoPlayerContext.Provider>
70
- );
71
- };
72
-
73
- // Custom hook to use the context
74
- export const useSoftBuildersVideoPlayerContext = () => {
75
- const context = useContext(SoftBuildersVideoPlayerContext);
76
- if (!context) {
77
- throw new Error(
78
- "useSoftBuildersVideoPlayerContext must be used within an SoftBuildersVideoPlayerProvider"
79
- );
80
- }
81
- return context;
82
- };
1
+ import React, {
2
+ createContext,
3
+ useContext,
4
+ useState,
5
+ ReactNode,
6
+ useEffect,
7
+ } from "react";
8
+ import Player from "video.js/dist/types/player";
9
+
10
+ interface SoftBuildersVideoPlayerContextType {
11
+ player: Player | undefined;
12
+ setPlayer: React.Dispatch<React.SetStateAction<Player | undefined>>;
13
+
14
+ currentTime: number;
15
+ setCurrentTime: (value: number) => void;
16
+
17
+ duration: number;
18
+ setDuration: React.Dispatch<React.SetStateAction<number>>;
19
+
20
+ // isPaused: boolean;
21
+ // setIsPaused: React.Dispatch<React.SetStateAction<boolean>>;
22
+
23
+ downloadedBufferPercentage: number;
24
+ downloadedBufferTime: number;
25
+ setDownloadedBufferTimeufferTime: React.Dispatch<
26
+ React.SetStateAction<number>
27
+ >;
28
+ }
29
+
30
+ const SoftBuildersVideoPlayerContext = createContext<
31
+ SoftBuildersVideoPlayerContextType | undefined
32
+ >(undefined);
33
+
34
+ // Create a provider component
35
+ export const SoftBuildersVideoPlayerProvider = ({
36
+ children,
37
+ }: {
38
+ children: ReactNode;
39
+ }) => {
40
+ const [player, setPlayer] = useState<Player | undefined>(undefined);
41
+ const [currentTime, setCurrentTime] = useState<number>(0);
42
+ const [duration, setDuration] = useState<number>(1);
43
+ // const [isPaused, setIsPaused] = useState(false);
44
+ const [downloadedBufferTime, setDownloadedBufferTimeufferTime] = useState(0);
45
+ const [downloadedBufferPercentage, setDownloadedBufferPercentage] =
46
+ useState(0);
47
+
48
+ useEffect(() => {
49
+ setDownloadedBufferPercentage((downloadedBufferTime * 100) / duration);
50
+ }, [downloadedBufferTime]);
51
+
52
+ return (
53
+ <SoftBuildersVideoPlayerContext.Provider
54
+ value={{
55
+ player,
56
+ setPlayer,
57
+ duration,
58
+ setDuration,
59
+ currentTime,
60
+ setCurrentTime: (value) => setCurrentTime(Math.floor(value)),
61
+ // isPaused,
62
+ // setIsPaused,
63
+ downloadedBufferTime,
64
+ setDownloadedBufferTimeufferTime,
65
+ downloadedBufferPercentage,
66
+ }}
67
+ >
68
+ {children}
69
+ </SoftBuildersVideoPlayerContext.Provider>
70
+ );
71
+ };
72
+
73
+ // Custom hook to use the context
74
+ export const useSoftBuildersVideoPlayerContext = () => {
75
+ const context = useContext(SoftBuildersVideoPlayerContext);
76
+ if (!context) {
77
+ throw new Error(
78
+ "useSoftBuildersVideoPlayerContext must be used within an SoftBuildersVideoPlayerProvider"
79
+ );
80
+ }
81
+ return context;
82
+ };