softbuilders-react-video-player 1.0.6 → 1.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (155) hide show
  1. package/dist/components/BigPlayButton/index.d.ts +1 -1
  2. package/dist/components/BigPlayButton/index.js +2 -3
  3. package/dist/components/BigPlayButton/index.js.map +1 -1
  4. package/dist/components/BigPlayButton/index.tsx +31 -0
  5. package/dist/components/BufferTracker/index.d.ts +1 -2
  6. package/dist/components/BufferTracker/index.js +3 -2
  7. package/dist/components/BufferTracker/index.js.map +1 -1
  8. package/dist/components/BufferTracker/index.tsx +19 -0
  9. package/dist/components/ChapterTooltip/index.d.ts +1 -2
  10. package/dist/components/ChapterTooltip/index.js +4 -13
  11. package/dist/components/ChapterTooltip/index.js.map +1 -1
  12. package/dist/components/ChapterTooltip/index.tsx +65 -0
  13. package/dist/components/ChaptersPanal/index.d.ts +1 -2
  14. package/dist/components/ChaptersPanal/index.js +3 -2
  15. package/dist/components/ChaptersPanal/index.js.map +1 -1
  16. package/dist/components/ChaptersPanal/index.tsx +40 -0
  17. package/dist/components/ControlBar/index.d.ts +1 -1
  18. package/dist/components/ControlBar/index.js +14 -31
  19. package/dist/components/ControlBar/index.js.map +1 -1
  20. package/dist/components/ControlBar/index.tsx +127 -0
  21. package/dist/components/CreateNoteMenu/index.d.ts +1 -2
  22. package/dist/components/CreateNoteMenu/index.js +3 -9
  23. package/dist/components/CreateNoteMenu/index.js.map +1 -1
  24. package/dist/components/CreateNoteMenu/index.tsx +61 -0
  25. package/dist/components/CurrentTimeLabel/index.d.ts +1 -2
  26. package/dist/components/CurrentTimeLabel/index.js +2 -2
  27. package/dist/components/CurrentTimeLabel/index.js.map +1 -1
  28. package/dist/components/CurrentTimeLabel/index.tsx +13 -0
  29. package/dist/components/CurrentTimeTracker/index.d.ts +1 -2
  30. package/dist/components/CurrentTimeTracker/index.js +3 -2
  31. package/dist/components/CurrentTimeTracker/index.js.map +1 -1
  32. package/dist/components/CurrentTimeTracker/index.tsx +18 -0
  33. package/dist/components/Menu/index.d.ts +1 -2
  34. package/dist/components/Menu/index.js +2 -7
  35. package/dist/components/Menu/index.js.map +1 -1
  36. package/dist/components/Menu/index.tsx +49 -0
  37. package/dist/components/MenuButton/index.d.ts +1 -1
  38. package/dist/components/MenuButton/index.js +3 -4
  39. package/dist/components/MenuButton/index.js.map +1 -1
  40. package/dist/components/MenuButton/index.tsx +67 -0
  41. package/dist/components/NoteTooltip/index.d.ts +1 -2
  42. package/dist/components/NoteTooltip/index.js +3 -7
  43. package/dist/components/NoteTooltip/index.js.map +1 -1
  44. package/dist/components/NoteTooltip/index.tsx +46 -0
  45. package/dist/components/NotesPanal/index.d.ts +1 -2
  46. package/dist/components/NotesPanal/index.js +3 -2
  47. package/dist/components/NotesPanal/index.js.map +1 -1
  48. package/dist/components/NotesPanal/index.tsx +34 -0
  49. package/dist/components/QualityMenu/index.d.ts +1 -2
  50. package/dist/components/QualityMenu/index.js +19 -28
  51. package/dist/components/QualityMenu/index.js.map +1 -1
  52. package/dist/components/QualityMenu/index.tsx +122 -0
  53. package/dist/components/Slider/index.d.ts +1 -1
  54. package/dist/components/Slider/index.js +2 -2
  55. package/dist/components/Slider/index.js.map +1 -1
  56. package/dist/components/Slider/index.tsx +37 -0
  57. package/dist/components/SoftBuildersVideoPlayer/index.d.ts +1 -1
  58. package/dist/components/SoftBuildersVideoPlayer/index.js +3 -2
  59. package/dist/components/SoftBuildersVideoPlayer/index.js.map +1 -1
  60. package/dist/components/SoftBuildersVideoPlayer/index.tsx +108 -0
  61. package/dist/components/SubtitleMenu/index.d.ts +1 -2
  62. package/dist/components/SubtitleMenu/index.js +12 -21
  63. package/dist/components/SubtitleMenu/index.js.map +1 -1
  64. package/dist/components/SubtitleMenu/index.tsx +108 -0
  65. package/dist/components/TimeSlider/index.d.ts +1 -2
  66. package/dist/components/TimeSlider/index.js +10 -12
  67. package/dist/components/TimeSlider/index.js.map +1 -1
  68. package/dist/components/TimeSlider/index.tsx +107 -0
  69. package/dist/components/TimeSliderContainer/index.d.ts +1 -2
  70. package/dist/components/TimeSliderContainer/index.js +2 -7
  71. package/dist/components/TimeSliderContainer/index.js.map +1 -1
  72. package/dist/components/TimeSliderContainer/index.tsx +35 -0
  73. package/dist/components/Tooltip/index.d.ts +1 -1
  74. package/dist/components/Tooltip/index.js +2 -2
  75. package/dist/components/Tooltip/index.js.map +1 -1
  76. package/dist/components/Tooltip/index.tsx +16 -0
  77. package/dist/components/VideoPlayerComponent/index.d.ts +1 -2
  78. package/dist/components/VideoPlayerComponent/index.js +5 -7
  79. package/dist/components/VideoPlayerComponent/index.js.map +1 -1
  80. package/dist/components/VideoPlayerComponent/index.tsx +244 -0
  81. package/dist/components/VideoPlayerComponent/provider.d.ts +1 -1
  82. package/dist/components/VideoPlayerComponent/provider.js +4 -3
  83. package/dist/components/VideoPlayerComponent/provider.js.map +1 -1
  84. package/dist/components/VideoPlayerComponent/provider.tsx +82 -0
  85. package/dist/components/VolumeSlider/index.d.ts +1 -2
  86. package/dist/components/VolumeSlider/index.js +3 -4
  87. package/dist/components/VolumeSlider/index.js.map +1 -1
  88. package/dist/components/VolumeSlider/index.tsx +52 -0
  89. package/dist/components/icons/BackwardIcon.d.ts +3 -0
  90. package/dist/components/icons/BackwardIcon.js +4 -0
  91. package/dist/components/icons/BackwardIcon.js.map +1 -0
  92. package/dist/components/icons/BackwardIcon.tsx +20 -0
  93. package/dist/components/icons/CheckedIcon.d.ts +3 -0
  94. package/dist/components/icons/CheckedIcon.js +4 -0
  95. package/dist/components/icons/CheckedIcon.js.map +1 -0
  96. package/dist/components/icons/CheckedIcon.tsx +20 -0
  97. package/dist/components/icons/ClosedNoteIcon.d.ts +3 -0
  98. package/dist/components/icons/ClosedNoteIcon.js +4 -0
  99. package/dist/components/icons/ClosedNoteIcon.js.map +1 -0
  100. package/dist/components/icons/ClosedNoteIcon.tsx +17 -0
  101. package/dist/components/icons/ForwardIcon.d.ts +3 -0
  102. package/dist/components/icons/ForwardIcon.js +4 -0
  103. package/dist/components/icons/ForwardIcon.js.map +1 -0
  104. package/dist/components/icons/ForwardIcon.tsx +20 -0
  105. package/dist/components/icons/FullScreenIcon.d.ts +3 -0
  106. package/dist/components/icons/FullScreenIcon.js +4 -0
  107. package/dist/components/icons/FullScreenIcon.js.map +1 -0
  108. package/dist/components/icons/FullScreenIcon.tsx +20 -0
  109. package/dist/components/icons/LeftArrowIcon.d.ts +3 -0
  110. package/dist/components/icons/LeftArrowIcon.js +4 -0
  111. package/dist/components/icons/LeftArrowIcon.js.map +1 -0
  112. package/dist/components/icons/LeftArrowIcon.tsx +20 -0
  113. package/dist/components/icons/MuteIcon.d.ts +3 -0
  114. package/dist/components/icons/MuteIcon.js +4 -0
  115. package/dist/components/icons/MuteIcon.js.map +1 -0
  116. package/dist/components/icons/MuteIcon.tsx +21 -0
  117. package/dist/components/icons/NoteIcon.d.ts +3 -0
  118. package/dist/components/icons/NoteIcon.js +4 -0
  119. package/dist/components/icons/NoteIcon.js.map +1 -0
  120. package/dist/components/icons/NoteIcon.tsx +17 -0
  121. package/dist/components/icons/OpenNoteIcon.d.ts +3 -0
  122. package/dist/components/icons/OpenNoteIcon.js +4 -0
  123. package/dist/components/icons/OpenNoteIcon.js.map +1 -0
  124. package/dist/components/icons/OpenNoteIcon.tsx +17 -0
  125. package/dist/components/icons/PauseIcon.d.ts +3 -0
  126. package/dist/components/icons/PauseIcon.js +4 -0
  127. package/dist/components/icons/PauseIcon.js.map +1 -0
  128. package/dist/components/icons/PauseIcon.tsx +14 -0
  129. package/dist/components/icons/PlayIcon.d.ts +3 -0
  130. package/dist/components/icons/PlayIcon.js +4 -0
  131. package/dist/components/icons/PlayIcon.js.map +1 -0
  132. package/dist/components/icons/PlayIcon.tsx +20 -0
  133. package/dist/components/icons/SettingsIcon.d.ts +3 -0
  134. package/dist/components/icons/SettingsIcon.js +4 -0
  135. package/dist/components/icons/SettingsIcon.js.map +1 -0
  136. package/dist/components/icons/SettingsIcon.tsx +17 -0
  137. package/dist/components/icons/SubtitlesIcon.d.ts +3 -0
  138. package/dist/components/icons/SubtitlesIcon.js +4 -0
  139. package/dist/components/icons/SubtitlesIcon.js.map +1 -0
  140. package/dist/components/icons/SubtitlesIcon.tsx +14 -0
  141. package/dist/components/icons/UnmuteIcon.d.ts +3 -0
  142. package/dist/components/icons/UnmuteIcon.js +4 -0
  143. package/dist/components/icons/UnmuteIcon.js.map +1 -0
  144. package/dist/components/icons/UnmuteIcon.tsx +17 -0
  145. package/dist/components/icons/index.d.ts +14 -0
  146. package/dist/components/icons/index.js +15 -0
  147. package/dist/components/icons/index.js.map +1 -0
  148. package/dist/components/icons/index.ts +14 -0
  149. package/dist/images/index.d.ts +14 -14
  150. package/dist/images/index.js +14 -14
  151. package/dist/images/index.js.map +1 -1
  152. package/dist/index.css +663 -0
  153. package/dist/index.d.mts +49 -0
  154. package/dist/index.mjs +1383 -0
  155. package/package.json +9 -4
@@ -0,0 +1,107 @@
1
+ import React, { useEffect, useState } from "react";
2
+ import Slider from "../Slider";
3
+ import { useSoftBuildersVideoPlayerContext } from "../VideoPlayerComponent/provider";
4
+ import { SoftBuildersVideoPlayerChapter } from "../../types";
5
+
6
+ const MIN = 0,
7
+ MAX = 100;
8
+ const DEFERENCE = Math.abs(MAX - MIN);
9
+ const BAR_PERCENTAGE_WIDTH = 0.5;
10
+
11
+ type Props = {
12
+ chapters: SoftBuildersVideoPlayerChapter[];
13
+ };
14
+
15
+ const TimeSlider = ({ chapters }: Props) => {
16
+ const [timeSlider, setTimeSlider] = useState(0);
17
+
18
+ const { player, duration, downloadedBufferPercentage } =
19
+ useSoftBuildersVideoPlayerContext();
20
+
21
+ const handleValueChange = (e: React.ChangeEvent<HTMLInputElement>) => {
22
+ const newTimeSlider = Number(e.target.value);
23
+ setTimeSlider(newTimeSlider);
24
+
25
+ const time = (newTimeSlider * duration) / DEFERENCE;
26
+
27
+ player?.currentTime(time);
28
+ };
29
+
30
+ useEffect(() => {
31
+ const intervalId = setInterval(() => {
32
+ const currentTime = player?.currentTime() || 0;
33
+
34
+ const time = (currentTime * DEFERENCE) / duration;
35
+
36
+ setTimeSlider(time);
37
+ }, 1000);
38
+
39
+ // Cleanup function to clear the interval
40
+ return () => clearInterval(intervalId);
41
+ }, [player, duration]);
42
+
43
+ const [maskCuttes, setMaskCuttes] = useState("");
44
+
45
+ useEffect(() => {
46
+ const arr: string[] = ["black 0%"];
47
+ chapters.forEach((c) => {
48
+ const startPercentage = Math.floor((c.startTime * 100) / duration);
49
+ const endPercentage = Math.floor((c.endTime * 100) / duration);
50
+ arr.push(`black ${startPercentage}%`);
51
+ arr.push(`transparent ${startPercentage}%`);
52
+ arr.push(`transparent ${startPercentage + BAR_PERCENTAGE_WIDTH}%`);
53
+
54
+ arr.push(`black ${startPercentage + BAR_PERCENTAGE_WIDTH}%`);
55
+ arr.push(`black ${endPercentage}%`);
56
+
57
+ arr.push(`transparent ${endPercentage}%`);
58
+ arr.push(`transparent ${endPercentage + BAR_PERCENTAGE_WIDTH}%`);
59
+
60
+ arr.push(`black ${endPercentage + BAR_PERCENTAGE_WIDTH}%`);
61
+ });
62
+ arr.push(`black 100%`);
63
+
64
+ setMaskCuttes(arr.toString());
65
+ }, [chapters, duration]);
66
+
67
+ return (
68
+ <div className=" sb-w-full sb-h-2 sb-flex sb-items-center sb-justify-center">
69
+ <div className="sb-absolute sb-top-0 sb-left-0 sb-w-full sb-z-10">
70
+ <Slider
71
+ value={timeSlider}
72
+ handleValueChange={handleValueChange}
73
+ min={MIN}
74
+ max={MAX}
75
+ style={{
76
+ background: "transparent",
77
+ }}
78
+ />
79
+ </div>
80
+
81
+ <div
82
+ className="sb-absolute sb-top-0 sb-left-0 sb-w-full sb-h-2 sb-bg-slate-400 sb-rounded-md"
83
+ style={{
84
+ background: `
85
+ linear-gradient(to right,
86
+ #f97316 0%,
87
+ #f97316 ${timeSlider}%,
88
+ #f9731640 ${timeSlider}%,
89
+ #f9731640 ${downloadedBufferPercentage}%,
90
+ #30303030 ${timeSlider}%,
91
+ #30303030 100%
92
+ )
93
+ `,
94
+ maskImage: `
95
+ linear-gradient(to right,
96
+ ${maskCuttes}
97
+ )
98
+ `,
99
+ maskSize: "100% 100%",
100
+ maskRepeat: "no-repeat",
101
+ }}
102
+ ></div>
103
+ </div>
104
+ );
105
+ };
106
+
107
+ export default TimeSlider;
@@ -1,8 +1,7 @@
1
- import React from "react";
2
1
  import { SoftBuildersVideoPlayerChapter, SoftBuildersVideoPlayerNote } from "../../types";
3
2
  type Props = {
4
3
  notes: SoftBuildersVideoPlayerNote[];
5
4
  chapters: SoftBuildersVideoPlayerChapter[];
6
5
  };
7
- declare const TimeSliderContainer: ({ notes, chapters }: Props) => React.JSX.Element;
6
+ declare const TimeSliderContainer: ({ notes, chapters }: Props) => import("react/jsx-runtime").JSX.Element;
8
7
  export default TimeSliderContainer;
@@ -1,14 +1,9 @@
1
- import React from "react";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import NotesPanal from "../NotesPanal";
3
3
  import ChaptersPanal from "../ChaptersPanal";
4
4
  import TimeSlider from "../TimeSlider";
5
5
  const TimeSliderContainer = ({ notes, chapters }) => {
6
- return (React.createElement("div", { id: "time-slider-container", className: "sb-w-full sb-relative sb-flex sb-items-center sb-justify-center" },
7
- React.createElement("div", { id: "notes-panal", className: "sb-absolute sb-w-full sb-h-full sb-top-[27%] sb-left-0" },
8
- React.createElement(NotesPanal, { notes: notes })),
9
- React.createElement("div", { className: "sb-absolute sb-w-full sb-h-full sb-top-0 sb-left-0" },
10
- React.createElement(ChaptersPanal, { chapters: chapters })),
11
- React.createElement(TimeSlider, { chapters: chapters })));
6
+ return (_jsxs("div", { id: "time-slider-container", className: "sb-w-full sb-relative sb-flex sb-items-center sb-justify-center", children: [_jsx("div", { id: "notes-panal", className: "sb-absolute sb-w-full sb-h-full sb-top-[27%] sb-left-0", children: _jsx(NotesPanal, { notes: notes }) }), _jsx("div", { className: "sb-absolute sb-w-full sb-h-full sb-top-0 sb-left-0", children: _jsx(ChaptersPanal, { chapters: chapters }) }), _jsx(TimeSlider, { chapters: chapters })] }));
12
7
  };
13
8
  export default TimeSliderContainer;
14
9
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/TimeSliderContainer/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,UAAU,MAAM,eAAe,CAAC;AACvC,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAC7C,OAAO,UAAU,MAAM,eAAe,CAAC;AAUvC,MAAM,mBAAmB,GAAG,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAS,EAAE,EAAE;IACzD,OAAO,CACL,6BACE,EAAE,EAAC,uBAAuB,EAC1B,SAAS,EAAC,iEAAiE;QAE3E,6BACE,EAAE,EAAC,aAAa,EAChB,SAAS,EAAC,wDAAwD;YAElE,oBAAC,UAAU,IAAC,KAAK,EAAE,KAAK,GAAI,CACxB;QAEN,6BAAK,SAAS,EAAC,oDAAoD;YACjE,oBAAC,aAAa,IAAC,QAAQ,EAAE,QAAQ,GAAI,CACjC;QACN,oBAAC,UAAU,IAAC,QAAQ,EAAE,QAAQ,GAAI,CAC9B,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/TimeSliderContainer/index.tsx"],"names":[],"mappings":";AACA,OAAO,UAAU,MAAM,eAAe,CAAC;AACvC,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAC7C,OAAO,UAAU,MAAM,eAAe,CAAC;AAUvC,MAAM,mBAAmB,GAAG,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAS,EAAE,EAAE;IACzD,OAAO,CACL,eACE,EAAE,EAAC,uBAAuB,EAC1B,SAAS,EAAC,iEAAiE,aAE3E,cACE,EAAE,EAAC,aAAa,EAChB,SAAS,EAAC,wDAAwD,YAElE,KAAC,UAAU,IAAC,KAAK,EAAE,KAAK,GAAI,GACxB,EAEN,cAAK,SAAS,EAAC,oDAAoD,YACjE,KAAC,aAAa,IAAC,QAAQ,EAAE,QAAQ,GAAI,GACjC,EACN,KAAC,UAAU,IAAC,QAAQ,EAAE,QAAQ,GAAI,IAC9B,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
@@ -0,0 +1,35 @@
1
+ import React from "react";
2
+ import NotesPanal from "../NotesPanal";
3
+ import ChaptersPanal from "../ChaptersPanal";
4
+ import TimeSlider from "../TimeSlider";
5
+ import {
6
+ SoftBuildersVideoPlayerChapter,
7
+ SoftBuildersVideoPlayerNote,
8
+ } from "../../types";
9
+
10
+ type Props = {
11
+ notes: SoftBuildersVideoPlayerNote[];
12
+ chapters: SoftBuildersVideoPlayerChapter[];
13
+ };
14
+ const TimeSliderContainer = ({ notes, chapters }: Props) => {
15
+ return (
16
+ <div
17
+ id="time-slider-container"
18
+ className="sb-w-full sb-relative sb-flex sb-items-center sb-justify-center"
19
+ >
20
+ <div
21
+ id="notes-panal"
22
+ className="sb-absolute sb-w-full sb-h-full sb-top-[27%] sb-left-0"
23
+ >
24
+ <NotesPanal notes={notes} />
25
+ </div>
26
+
27
+ <div className="sb-absolute sb-w-full sb-h-full sb-top-0 sb-left-0">
28
+ <ChaptersPanal chapters={chapters} />
29
+ </div>
30
+ <TimeSlider chapters={chapters} />
31
+ </div>
32
+ );
33
+ };
34
+
35
+ export default TimeSliderContainer;
@@ -3,5 +3,5 @@ type Props = {
3
3
  open: boolean;
4
4
  children: React.ReactNode;
5
5
  };
6
- declare const Tooltip: ({ open, children }: Props) => React.JSX.Element;
6
+ declare const Tooltip: ({ open, children }: Props) => import("react/jsx-runtime").JSX.Element;
7
7
  export default Tooltip;
@@ -1,8 +1,8 @@
1
- import React from "react";
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  const Tooltip = ({ open, children }) => {
3
3
  if (!open)
4
4
  return null;
5
- return (React.createElement("div", { className: "sb-absolute sb-bottom-full sb-mb-2 sb-left-1/2 sb-transform sb--translate-x-1/2 sb-z-10 sb-whitespace-nowrap" }, children));
5
+ return (_jsx("div", { className: "sb-absolute sb-bottom-full sb-mb-2 sb-left-1/2 sb-transform sb--translate-x-1/2 sb-z-10 sb-whitespace-nowrap", children: children }));
6
6
  };
7
7
  export default Tooltip;
8
8
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/Tooltip/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,MAAM,OAAO,GAAG,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAS,EAAE,EAAE;IAC5C,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAC;IACvB,OAAO,CACL,6BAAK,SAAS,EAAC,8GAA8G,IAC1H,QAAQ,CACL,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/Tooltip/index.tsx"],"names":[],"mappings":";AAMA,MAAM,OAAO,GAAG,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAS,EAAE,EAAE;IAC5C,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAC;IACvB,OAAO,CACL,cAAK,SAAS,EAAC,8GAA8G,YAC1H,QAAQ,GACL,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -0,0 +1,16 @@
1
+ import React from "react";
2
+
3
+ type Props = {
4
+ open: boolean;
5
+ children: React.ReactNode;
6
+ };
7
+ const Tooltip = ({ open, children }: Props) => {
8
+ if (!open) return null;
9
+ return (
10
+ <div className="sb-absolute sb-bottom-full sb-mb-2 sb-left-1/2 sb-transform sb--translate-x-1/2 sb-z-10 sb-whitespace-nowrap">
11
+ {children}
12
+ </div>
13
+ );
14
+ };
15
+
16
+ export default Tooltip;
@@ -1,4 +1,3 @@
1
- import React from "react";
2
1
  import "video.js/dist/video-js.css";
3
2
  import { SoftBuildersVideoPlayerChapter, SoftBuildersVideoPlayerNote, SoftBuildersVideoPlayerOptions } from "../../types";
4
3
  import "./style/style.css";
@@ -13,5 +12,5 @@ export type Props<T = any> = {
13
12
  onPlay?: (time: number) => void;
14
13
  onPause?: (time: number) => void;
15
14
  };
16
- declare const VideoPlayerComponent: <T>({ id, options, notes, chapters, startTime, handleSaveNoteAction, onPlay, onPause, }: Props<T>) => React.JSX.Element;
15
+ declare const VideoPlayerComponent: <T>({ id, options, notes, chapters, startTime, handleSaveNoteAction, onPlay, onPause, }: Props<T>) => import("react/jsx-runtime").JSX.Element;
17
16
  export default VideoPlayerComponent;
@@ -1,4 +1,5 @@
1
- import React, { useEffect, useRef, useState } from "react";
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useEffect, useRef, useState } from "react";
2
3
  import ReactDOM from "react-dom/client";
3
4
  import videojs from "video.js";
4
5
  import "video.js/dist/video-js.css";
@@ -17,7 +18,7 @@ const renderBigPlayButton = (id, player, isPaused, setIsPaused) => {
17
18
  // If bigPlayButtonRoot hasn't been created, create it
18
19
  bigPlayButtonRoot[id] = ReactDOM.createRoot(element);
19
20
  }
20
- bigPlayButtonRoot[id].render(React.createElement(BigPlayButton, { player: player, isPaused: isPaused, setIsPaused: setIsPaused }));
21
+ bigPlayButtonRoot[id].render(_jsx(BigPlayButton, { player: player, isPaused: isPaused, setIsPaused: setIsPaused }));
21
22
  }
22
23
  }
23
24
  };
@@ -32,8 +33,7 @@ const renderControlBar = (id, player, isPaused, setIsPaused, duration, notes, ch
32
33
  controlBarRoot[id] = ReactDOM.createRoot(element);
33
34
  }
34
35
  element.style.display = "block";
35
- controlBarRoot[id].render(React.createElement(SoftBuildersVideoPlayerProvider, null,
36
- React.createElement(ControlBar, { player: player, isPaused: isPaused, setIsPaused: setIsPaused, duration: duration, notes: notes, chapters: chapters, seekStep: seekStep, handleSaveNoteAction: handleSaveNoteAction })));
36
+ controlBarRoot[id].render(_jsx(SoftBuildersVideoPlayerProvider, { children: _jsx(ControlBar, { player: player, isPaused: isPaused, setIsPaused: setIsPaused, duration: duration, notes: notes, chapters: chapters, seekStep: seekStep, handleSaveNoteAction: handleSaveNoteAction }) }));
37
37
  }
38
38
  }
39
39
  };
@@ -132,9 +132,7 @@ const VideoPlayerComponent = ({ id, options, notes, chapters, startTime = 0, han
132
132
  return () => clearInterval(intervalId);
133
133
  }
134
134
  }, []);
135
- return (React.createElement("div", { id: `video-container-${id}`, className: "sb-relative sb-rounded-md sb-overflow-hidden" },
136
- React.createElement("div", { "data-vjs-player": true },
137
- React.createElement("div", { ref: videoRef }))));
135
+ return (_jsx("div", { id: `video-container-${id}`, className: "sb-relative sb-rounded-md sb-overflow-hidden", children: _jsx("div", { "data-vjs-player": true, children: _jsx("div", { ref: videoRef }) }) }));
138
136
  };
139
137
  export default VideoPlayerComponent;
140
138
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/VideoPlayerComponent/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC3D,OAAO,QAAQ,MAAM,kBAAkB,CAAC;AACxC,OAAO,OAAO,MAAM,UAAU,CAAC;AAE/B,OAAO,4BAA4B,CAAC;AACpC,OAAO,UAAU,MAAM,eAAe,CAAC;AAOvC,OAAO,mBAAmB,CAAC;AAC3B,OAAO,2BAA2B,CAAC;AACnC,OAAO,EAAE,+BAA+B,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAE7C,IAAI,iBAAiB,GAEjB,EAAE,CAAC;AAEP,MAAM,mBAAmB,GAAG,CAC1B,EAAU,EACV,MAA0B,EAC1B,QAAiB,EACjB,WAA0D,EAC1D,EAAE;IACF,MAAM,SAAS,GA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;YACZ,MAAM,iBAAiB,GAAG,UAAU,CAAC,GAAG,EAAE;gBACxC,mBAAmB,CAAC,EAAE,EAAE,SAAS,CAAC,OAAO,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC;YACpE,CAAC,EAAE,GAAG,CAAC,CAAC;YAER,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,iBAAiB,CAAC,CAAC,CAAC,uBAAuB;QACvE,CAAC;IACH,CAAC,EAAE,CAAC,EAAE,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC;IAE5B,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,SAAS,CAAC,OAAO,EAAE,CAAC;YACtB,MAAM,UAAU,GAAG,WAAW,CAAC,GAAG,EAAE;gBAClC,WAAW,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;YAC1C,CAAC,EAAE,GAAG,CAAC,CAAC;YAER,OAAO,GAAG,EAAE,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;QACzC,CAAC;IACH,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,CACL,cACE,EAAE,EAAE,mBAAmB,EAAE,EAAE,EAC3B,SAAS,EAAC,8CAA8C,YAExD,iDACE,cAAK,GAAG,EAAE,QAAQ,GAAI,GAClB,GACF,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
@@ -0,0 +1,244 @@
1
+ import React, { useEffect, useRef, useState } from "react";
2
+ import ReactDOM from "react-dom/client";
3
+ import videojs from "video.js";
4
+ import Player from "video.js/dist/types/player";
5
+ import "video.js/dist/video-js.css";
6
+ import ControlBar from "../ControlBar";
7
+ import {
8
+ SoftBuildersVideoPlayerChapter,
9
+ SoftBuildersVideoPlayerNote,
10
+ SoftBuildersVideoPlayerOptions,
11
+ } from "../../types";
12
+
13
+ import "./style/style.css";
14
+ import "../../styles/tailwind.css";
15
+ import { SoftBuildersVideoPlayerProvider } from "./provider";
16
+ import BigPlayButton from "../BigPlayButton";
17
+
18
+ let bigPlayButtonRoot: {
19
+ [key: string]: ReactDOM.Root | undefined;
20
+ } = {};
21
+
22
+ const renderBigPlayButton = (
23
+ id: string,
24
+ player: Player | undefined,
25
+ isPaused: boolean,
26
+ setIsPaused: React.Dispatch<React.SetStateAction<boolean>>
27
+ ) => {
28
+ const container = document.getElementById(`video-container-${id}`);
29
+ if (container) {
30
+ const element: any = container.querySelector(".vjs-big-play-button");
31
+ if (element) {
32
+ if (!bigPlayButtonRoot[id]) {
33
+ // If bigPlayButtonRoot hasn't been created, create it
34
+ bigPlayButtonRoot[id] = ReactDOM.createRoot(element as HTMLElement);
35
+ }
36
+
37
+ bigPlayButtonRoot[id].render(
38
+ <BigPlayButton
39
+ player={player}
40
+ isPaused={isPaused}
41
+ setIsPaused={setIsPaused}
42
+ />
43
+ );
44
+ }
45
+ }
46
+ };
47
+
48
+ let controlBarRoot: {
49
+ [key: string]: ReactDOM.Root | undefined;
50
+ } = {};
51
+
52
+ const renderControlBar = <T,>(
53
+ id: string,
54
+ player: Player | undefined,
55
+ isPaused: boolean,
56
+ setIsPaused: React.Dispatch<React.SetStateAction<boolean>>,
57
+ duration: number,
58
+ notes: SoftBuildersVideoPlayerNote[],
59
+ chapters: SoftBuildersVideoPlayerChapter[],
60
+ seekStep: number = 5,
61
+ handleSaveNoteAction?: (time: number, note: string) => Promise<T>
62
+ ) => {
63
+ const container = document.getElementById(`video-container-${id}`);
64
+ if (container) {
65
+ const element: any = container.querySelector(".vjs-control-bar");
66
+ if (element) {
67
+ if (!controlBarRoot[id]) {
68
+ // If controlBarRoot hasn't been created, create it
69
+ controlBarRoot[id] = ReactDOM.createRoot(element as HTMLElement);
70
+ }
71
+
72
+ element.style.display = "block";
73
+ controlBarRoot[id].render(
74
+ <SoftBuildersVideoPlayerProvider>
75
+ <ControlBar
76
+ player={player}
77
+ isPaused={isPaused}
78
+ setIsPaused={setIsPaused}
79
+ duration={duration}
80
+ notes={notes}
81
+ chapters={chapters}
82
+ seekStep={seekStep}
83
+ handleSaveNoteAction={handleSaveNoteAction}
84
+ />
85
+ </SoftBuildersVideoPlayerProvider>
86
+ );
87
+ }
88
+ }
89
+ };
90
+
91
+ export type Props<T = any> = {
92
+ id: string;
93
+ options: SoftBuildersVideoPlayerOptions;
94
+ notes: SoftBuildersVideoPlayerNote[];
95
+ chapters: SoftBuildersVideoPlayerChapter[];
96
+ startTime?: number;
97
+ handleSaveNoteAction?: (time: number, note: string) => Promise<T>;
98
+ onPlay?: (time: number) => void;
99
+ onPause?: (time: number) => void;
100
+ };
101
+
102
+ const VideoPlayerComponent = <T,>({
103
+ id,
104
+ options,
105
+ notes,
106
+ chapters,
107
+ startTime = 0,
108
+ handleSaveNoteAction,
109
+ onPlay,
110
+ onPause,
111
+ }: Props<T>) => {
112
+ const videoRef = useRef<any>(undefined);
113
+ const playerRef = useRef<Player | undefined>(undefined);
114
+
115
+ const [isReady, setIsReady] = useState(false);
116
+ const [isPaused, setIsPaused] = useState(!options.autoplay);
117
+ const [duration, setDuratoin] = useState(1);
118
+
119
+ const onReady = (player: Player) => {
120
+ playerRef.current = player;
121
+ setIsReady(true);
122
+
123
+ player.currentTime(startTime);
124
+
125
+ player.on("waiting", () => {});
126
+
127
+ player.on("dispose", () => {
128
+ videojs.log("player will dispose");
129
+ setIsReady(false);
130
+ });
131
+
132
+ player.on("loadedmetadata", () => {
133
+ const d = player.duration();
134
+ setDuratoin(d);
135
+ });
136
+ };
137
+
138
+ useEffect(() => {
139
+ if (!playerRef.current) {
140
+ const videoElement = document.createElement("video-js");
141
+ videoElement.classList.add("vjs-big-play-centered");
142
+ videoRef.current.appendChild(videoElement);
143
+
144
+ playerRef.current = videojs(videoElement, options, () => {
145
+ onReady(playerRef.current as Player);
146
+ });
147
+ }
148
+
149
+ return () => {
150
+ if (playerRef.current) {
151
+ // Dispose of the player properly on component unmount
152
+ playerRef.current.dispose();
153
+ playerRef.current = undefined;
154
+
155
+ // Defer unmounting of big play button and control bar to avoid race conditions
156
+ setTimeout(() => {
157
+ if (bigPlayButtonRoot[id]) {
158
+ bigPlayButtonRoot[id].unmount();
159
+ bigPlayButtonRoot[id] = undefined;
160
+ }
161
+ if (controlBarRoot[id]) {
162
+ controlBarRoot[id].unmount();
163
+ controlBarRoot[id] = undefined;
164
+ }
165
+ }, 0);
166
+ }
167
+ };
168
+ }, [options]);
169
+
170
+ useEffect(() => {
171
+ if (playerRef && playerRef?.current && isReady) {
172
+ const currentTime = playerRef.current.currentTime() || 0;
173
+
174
+ if (isPaused) {
175
+ if (onPause) onPause(currentTime);
176
+ } else {
177
+ if (onPlay) onPlay(currentTime);
178
+ }
179
+ }
180
+ }, [isPaused, isReady]);
181
+
182
+ useEffect(() => {
183
+ if (isReady) {
184
+ const controlBarTimeout = setTimeout(() => {
185
+ renderControlBar(
186
+ id,
187
+ playerRef.current,
188
+ isPaused,
189
+ setIsPaused,
190
+ duration,
191
+ notes,
192
+ chapters,
193
+ 5,
194
+ handleSaveNoteAction
195
+ );
196
+ }, 500);
197
+
198
+ return () => clearTimeout(controlBarTimeout); // Clean up the timeout
199
+ }
200
+ }, [
201
+ id,
202
+ playerRef,
203
+ isPaused,
204
+ setIsPaused,
205
+ notes,
206
+ chapters,
207
+ isReady,
208
+ handleSaveNoteAction,
209
+ duration,
210
+ ]);
211
+
212
+ useEffect(() => {
213
+ if (isReady) {
214
+ const playButtonTimeout = setTimeout(() => {
215
+ renderBigPlayButton(id, playerRef.current, isPaused, setIsPaused);
216
+ }, 500);
217
+
218
+ return () => clearTimeout(playButtonTimeout); // Clean up the timeout
219
+ }
220
+ }, [id, isPaused, isReady]);
221
+
222
+ useEffect(() => {
223
+ if (playerRef.current) {
224
+ const intervalId = setInterval(() => {
225
+ setIsPaused(playerRef.current.paused());
226
+ }, 500);
227
+
228
+ return () => clearInterval(intervalId);
229
+ }
230
+ }, []);
231
+
232
+ return (
233
+ <div
234
+ id={`video-container-${id}`}
235
+ className="sb-relative sb-rounded-md sb-overflow-hidden"
236
+ >
237
+ <div data-vjs-player>
238
+ <div ref={videoRef} />
239
+ </div>
240
+ </div>
241
+ );
242
+ };
243
+
244
+ export default VideoPlayerComponent;
@@ -13,6 +13,6 @@ interface SoftBuildersVideoPlayerContextType {
13
13
  }
14
14
  export declare const SoftBuildersVideoPlayerProvider: ({ children, }: {
15
15
  children: ReactNode;
16
- }) => React.JSX.Element;
16
+ }) => import("react/jsx-runtime").JSX.Element;
17
17
  export declare const useSoftBuildersVideoPlayerContext: () => SoftBuildersVideoPlayerContextType;
18
18
  export {};
@@ -1,4 +1,5 @@
1
- import React, { createContext, useContext, useState, useEffect, } from "react";
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { createContext, useContext, useState, useEffect, } from "react";
2
3
  const SoftBuildersVideoPlayerContext = createContext(undefined);
3
4
  // Create a provider component
4
5
  export const SoftBuildersVideoPlayerProvider = ({ children, }) => {
@@ -11,7 +12,7 @@ export const SoftBuildersVideoPlayerProvider = ({ children, }) => {
11
12
  useEffect(() => {
12
13
  setDownloadedBufferPercentage((downloadedBufferTime * 100) / duration);
13
14
  }, [downloadedBufferTime]);
14
- return (React.createElement(SoftBuildersVideoPlayerContext.Provider, { value: {
15
+ return (_jsx(SoftBuildersVideoPlayerContext.Provider, { value: {
15
16
  player,
16
17
  setPlayer,
17
18
  duration,
@@ -23,7 +24,7 @@ export const SoftBuildersVideoPlayerProvider = ({ children, }) => {
23
24
  downloadedBufferTime,
24
25
  setDownloadedBufferTimeufferTime,
25
26
  downloadedBufferPercentage,
26
- } }, children));
27
+ }, children: children }));
27
28
  };
28
29
  // Custom hook to use the context
29
30
  export const useSoftBuildersVideoPlayerContext = () => {
@@ -1 +1 @@
1
- {"version":3,"file":"provider.js","sourceRoot":"","sources":["../../../src/components/VideoPlayerComponent/provider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EACZ,aAAa,EACb,UAAU,EACV,QAAQ,EAER,SAAS,GACV,MAAM,OAAO,CAAC;AAuBf,MAAM,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ACZ,eAAe;YACf,oBAAoB;YACpB,gCAAgC;YAChC,0BAA0B;SAC3B,YAEA,QAAQ,GAC+B,CAC3C,CAAC;AACJ,CAAC,CAAC;AAEF,iCAAiC;AACjC,MAAM,CAAC,MAAM,iCAAiC,GAAG,GAAG,EAAE;IACpD,MAAM,OAAO,GAAG,UAAU,CAAC,8BAA8B,CAAC,CAAC;IAC3D,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CACb,0FAA0F,CAC3F,CAAC;IACJ,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC"}
@@ -0,0 +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
+ };