softbuilders-react-video-player 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +126 -0
  3. package/dist/components/BigPlayButton/index.d.ts +9 -0
  4. package/dist/components/BigPlayButton/index.js +15 -0
  5. package/dist/components/BigPlayButton/index.js.map +1 -0
  6. package/dist/components/BufferTracker/index.d.ts +3 -0
  7. package/dist/components/BufferTracker/index.js +16 -0
  8. package/dist/components/BufferTracker/index.js.map +1 -0
  9. package/dist/components/ChapterTooltip/index.d.ts +11 -0
  10. package/dist/components/ChapterTooltip/index.js +36 -0
  11. package/dist/components/ChapterTooltip/index.js.map +1 -0
  12. package/dist/components/ChaptersPanal/index.d.ts +7 -0
  13. package/dist/components/ChaptersPanal/index.js +19 -0
  14. package/dist/components/ChaptersPanal/index.js.map +1 -0
  15. package/dist/components/ControlBar/index.d.ts +15 -0
  16. package/dist/components/ControlBar/index.js +64 -0
  17. package/dist/components/ControlBar/index.js.map +1 -0
  18. package/dist/components/CreateNoteMenu/index.d.ts +6 -0
  19. package/dist/components/CreateNoteMenu/index.js +29 -0
  20. package/dist/components/CreateNoteMenu/index.js.map +1 -0
  21. package/dist/components/CurrentTimeLabel/index.d.ts +4 -0
  22. package/dist/components/CurrentTimeLabel/index.js +10 -0
  23. package/dist/components/CurrentTimeLabel/index.js.map +1 -0
  24. package/dist/components/CurrentTimeTracker/index.d.ts +3 -0
  25. package/dist/components/CurrentTimeTracker/index.js +15 -0
  26. package/dist/components/CurrentTimeTracker/index.js.map +1 -0
  27. package/dist/components/Menu/index.d.ts +6 -0
  28. package/dist/components/Menu/index.js +11 -0
  29. package/dist/components/Menu/index.js.map +1 -0
  30. package/dist/components/MenuButton/index.d.ts +8 -0
  31. package/dist/components/MenuButton/index.js +31 -0
  32. package/dist/components/MenuButton/index.js.map +1 -0
  33. package/dist/components/NoteTooltip/index.d.ts +10 -0
  34. package/dist/components/NoteTooltip/index.js +24 -0
  35. package/dist/components/NoteTooltip/index.js.map +1 -0
  36. package/dist/components/NotesPanal/index.d.ts +7 -0
  37. package/dist/components/NotesPanal/index.js +17 -0
  38. package/dist/components/NotesPanal/index.js.map +1 -0
  39. package/dist/components/QualityMenu/index.d.ts +4 -0
  40. package/dist/components/QualityMenu/index.js +53 -0
  41. package/dist/components/QualityMenu/index.js.map +1 -0
  42. package/dist/components/Slider/index.d.ts +10 -0
  43. package/dist/components/Slider/index.js +22 -0
  44. package/dist/components/Slider/index.js.map +1 -0
  45. package/dist/components/Slider/style.css +15 -0
  46. package/dist/components/SoftBuildersVideoPlayer/index.d.ts +13 -0
  47. package/dist/components/SoftBuildersVideoPlayer/index.js +55 -0
  48. package/dist/components/SoftBuildersVideoPlayer/index.js.map +1 -0
  49. package/dist/components/SubtitleMenu/index.d.ts +4 -0
  50. package/dist/components/SubtitleMenu/index.js +54 -0
  51. package/dist/components/SubtitleMenu/index.js.map +1 -0
  52. package/dist/components/TimeSlider/index.d.ts +7 -0
  53. package/dist/components/TimeSlider/index.js +69 -0
  54. package/dist/components/TimeSlider/index.js.map +1 -0
  55. package/dist/components/TimeSliderContainer/index.d.ts +8 -0
  56. package/dist/components/TimeSliderContainer/index.js +14 -0
  57. package/dist/components/TimeSliderContainer/index.js.map +1 -0
  58. package/dist/components/Tooltip/index.d.ts +7 -0
  59. package/dist/components/Tooltip/index.js +8 -0
  60. package/dist/components/Tooltip/index.js.map +1 -0
  61. package/dist/components/VideoPlayerComponent/index.d.ts +17 -0
  62. package/dist/components/VideoPlayerComponent/index.js +140 -0
  63. package/dist/components/VideoPlayerComponent/index.js.map +1 -0
  64. package/dist/components/VideoPlayerComponent/provider.d.ts +18 -0
  65. package/dist/components/VideoPlayerComponent/provider.js +36 -0
  66. package/dist/components/VideoPlayerComponent/provider.js.map +1 -0
  67. package/dist/components/VideoPlayerComponent/style/style.css +36 -0
  68. package/dist/components/VolumeSlider/index.d.ts +4 -0
  69. package/dist/components/VolumeSlider/index.js +28 -0
  70. package/dist/components/VolumeSlider/index.js.map +1 -0
  71. package/dist/icons/index.d.ts +14 -0
  72. package/dist/icons/index.js +15 -0
  73. package/dist/icons/index.js.map +1 -0
  74. package/dist/index.d.ts +3 -0
  75. package/dist/index.js +3 -0
  76. package/dist/index.js.map +1 -0
  77. package/dist/styles/tailwind.css +778 -0
  78. package/dist/types.d.ts +33 -0
  79. package/dist/types.js +2 -0
  80. package/dist/types.js.map +1 -0
  81. package/dist/utils/index.d.ts +2 -0
  82. package/dist/utils/index.js +51 -0
  83. package/dist/utils/index.js.map +1 -0
  84. package/package.json +37 -0
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ type QualityMenuProps = {};
3
+ declare const QualityMenu: ({}: QualityMenuProps) => React.JSX.Element;
4
+ export default QualityMenu;
@@ -0,0 +1,53 @@
1
+ import React, { useEffect, useState } from "react";
2
+ import MenuButton from "../MenuButton";
3
+ import { useSoftBuildersVideoPlayerContext } from "../VideoPlayerComponent/provider";
4
+ import { CheckedIcon, SettingsIcon, LeftArrowIcon, } from "../../icons";
5
+ const QualityOption = ({ isSelected, quality, onClick, }) => {
6
+ return (React.createElement("button", { className: "hover:sb-text-orange-500 sb-p-2", onClick: onClick },
7
+ React.createElement("div", { className: "sb-grid sb-grid-cols-12 sb-items-center sb-gap-2" },
8
+ React.createElement("div", { className: "sb-col-span-3" }, isSelected ? React.createElement(CheckedIcon, { className: "sb-w-5 sb-h-5" }) : React.createElement("div", null)),
9
+ React.createElement("p", { className: "sb-text-left sb-col-span-9" }, quality.label))));
10
+ };
11
+ const QualityMenu = ({}) => {
12
+ const { player } = useSoftBuildersVideoPlayerContext();
13
+ const [closeMenuFunction, setCloseMenuFunction] = useState(undefined);
14
+ const [qualities, setQualities] = useState([]);
15
+ const [currentQualitySrc, setCurrentQualitySrc] = useState(undefined);
16
+ useEffect(() => {
17
+ if (player) {
18
+ const sources = player.currentSources();
19
+ const qs = JSON.parse(JSON.stringify(sources));
20
+ setQualities(qs);
21
+ const source = player.currentSource();
22
+ const quality = JSON.parse(JSON.stringify(source));
23
+ setCurrentQualitySrc(quality.src);
24
+ }
25
+ }, [player]);
26
+ return (React.createElement(MenuButton, { buttonContent: React.createElement(SettingsIcon, { className: "sb-w-3 sb-h-3" }), menuContent: React.createElement("div", { className: "sb-rounded-md sb-bg-[#303030] sb-bg-opacity-50 sb-py-5 sb-w-[150px]" },
27
+ React.createElement("div", { className: "sb-flex sb-flex-col sb-gap-3" },
28
+ React.createElement("div", { className: "sb-px-5 sb-flex sb-flex-row sb-gap-3 sb-items-start" },
29
+ React.createElement("button", { onClick: () => {
30
+ if (closeMenuFunction) {
31
+ closeMenuFunction();
32
+ }
33
+ }, className: "hover:sb-scale-150" },
34
+ React.createElement(LeftArrowIcon, { className: "sb-w-3 sb-h-3" })),
35
+ React.createElement("h3", null, "Quality")),
36
+ React.createElement("div", { className: "sb-w-full sb-h-[.1px] sb-bg-[#AAAAAA] sb-bg-opacity-70" }),
37
+ React.createElement("div", { className: "sb-px-5 sb-flex sb-flex-col sb-gap-3 sb-items-start" }, qualities.map((q, i) => {
38
+ return (React.createElement(QualityOption, { key: `quality-${q.label}-${i}`, isSelected: currentQualitySrc === q.src, quality: q, onClick: () => {
39
+ const source = qualities.find((_q) => q.label == _q.label);
40
+ if (source && source.src != currentQualitySrc) {
41
+ player === null || player === void 0 ? void 0 : player.src(source.src);
42
+ const currentTime = player === null || player === void 0 ? void 0 : player.currentTime();
43
+ setCurrentQualitySrc(source.src);
44
+ player === null || player === void 0 ? void 0 : player.currentTime(currentTime);
45
+ player === null || player === void 0 ? void 0 : player.play();
46
+ }
47
+ } }));
48
+ })))), close: (fn) => {
49
+ setCloseMenuFunction(() => fn);
50
+ } }));
51
+ };
52
+ export default QualityMenu;
53
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/QualityMenu/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAe,SAAS,EAAE,QAAQ,EAAE,MA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,uBAAN,MAAM,CAAE,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;gCACxB,MAAM,WAAW,GAAG,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,WAAW,EAAE,CAAC;gCAC1C,oBAAoB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;gCACjC,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,WAAW,CAAC,WAAW,CAAC,CAAC;gCACjC,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI,EAAE,CAAC;4BACjB,CAAC;wBACH,CAAC,GACD,CACH,CAAC;gBACJ,CAAC,CAAC,CACE,CACF,CACF,EAER,KAAK,EAAE,CAAC,EAAY,EAAE,EAAE;YACtB,oBAAoB,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC;QACjC,CAAC,GACD,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -0,0 +1,10 @@
1
+ import React, { InputHTMLAttributes } from "react";
2
+ import "./style.css";
3
+ type Props = {
4
+ value: number;
5
+ handleValueChange: React.ChangeEventHandler<HTMLInputElement>;
6
+ min?: number;
7
+ max?: number;
8
+ } & InputHTMLAttributes<HTMLInputElement>;
9
+ declare const Slider: ({ value, handleValueChange, min, max, ...rest }: Props) => React.JSX.Element;
10
+ export default Slider;
@@ -0,0 +1,22 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import React from "react";
13
+ import "./style.css";
14
+ const Slider = (_a) => {
15
+ var { value, handleValueChange, min = 0, max = 100 } = _a, rest = __rest(_a, ["value", "handleValueChange", "min", "max"]);
16
+ return (React.createElement("input", Object.assign({ type: "range", min: min, max: max, value: value, onChange: handleValueChange, className: "sb-w-full sb-h-2 sb-bg-transparent sb-bg-opacity-50 sb-rounded-lg sb-appearance-none sb-cursor-pointer sb-range-slider sb-slider-thumb " +
17
+ rest.className, style: {
18
+ background: `linear-gradient(to right, #f97316 ${value}%, #30303070 ${value}%)`,
19
+ } }, rest)));
20
+ };
21
+ export default Slider;
22
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/Slider/index.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAwD,MAAM,OAAO,CAAC;AAC7E,OAAO,aAAa,CAAC;AASrB,MAAM,MAAM,GAAG,CAAC,EAMR,EAAE,EAAE;QANI,EACd,KAAK,EACL,iBAAiB,EACjB,GAAG,GAAG,CAAC,EACP,GAAG,GAAG,GAAG,OAEH,EADH,IAAI,cALO,4CAMf,CADQ;IAEP,OAAO,CACL,6CACE,IAAI,EAAC,OAAO,EACZ,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,iBAAiB,EAC3B,SAAS,EACP,yIAAyI;YACzI,IAAI,CAAC,SAAS,EAEhB,KAAK,EAAE;YACL,UAAU,EAAE,qCAAqC,KAAK,gBAAgB,KAAK,IAAI;SAChF,IACG,IAAI,EACR,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,MAAM,CAAC"}
@@ -0,0 +1,15 @@
1
+ /* Styling the slider track */
2
+
3
+ input[type="range"]::-webkit-slider-thumb {
4
+ -webkit-appearance: none;
5
+ appearance: none;
6
+ width: 20px;
7
+ height: 20px;
8
+ border-radius: 50%;
9
+ background: white;
10
+ cursor: pointer;
11
+ }
12
+
13
+ input[type="range"]:focus {
14
+ outline: none;
15
+ }
@@ -0,0 +1,13 @@
1
+ import React from "react";
2
+ import { SoftBuildersVideoPlayerChapter, SoftBuildersVideoPlayerNote, SoftBuildersVideoPlayerOptions } from "../../types";
3
+ export type Props<T = any> = {
4
+ options: SoftBuildersVideoPlayerOptions;
5
+ notes: SoftBuildersVideoPlayerNote[];
6
+ chapters: SoftBuildersVideoPlayerChapter[];
7
+ startTime?: number;
8
+ handleSaveNoteAction?: (time: number, note: string) => Promise<T>;
9
+ onPlay?: (time: number) => void;
10
+ onPause?: (time: number) => void;
11
+ };
12
+ declare const SoftBuildersVideoPlayer: React.MemoExoticComponent<(<T>({ options, notes, chapters, startTime, handleSaveNoteAction, onPlay, onPause, }: Props<T>) => React.JSX.Element)>;
13
+ export default SoftBuildersVideoPlayer;
@@ -0,0 +1,55 @@
1
+ import React, { memo, useEffect, useState } from "react";
2
+ import VideoPlayerComponent from "../VideoPlayerComponent";
3
+ import { convertSRTtoVTT } from "../../utils";
4
+ const DEFAULT_OPTIONS = {
5
+ autoplay: false,
6
+ controls: true,
7
+ fluid: true,
8
+ muted: true,
9
+ height: 420,
10
+ width: 720,
11
+ sources: [],
12
+ tracks: [],
13
+ };
14
+ const Component = ({ options, notes, chapters, startTime = 0, handleSaveNoteAction, onPlay, onPause, }) => {
15
+ options = Object.assign(Object.assign({}, options), { responsive: true, inactivityTimeout: 0, fullscreen: {
16
+ navigationUI: "hide",
17
+ } });
18
+ if (options.autoplay === undefined)
19
+ options.autoplay = DEFAULT_OPTIONS.autoplay;
20
+ if (options.controls === undefined)
21
+ options.controls = DEFAULT_OPTIONS.controls;
22
+ if (options.fluid === undefined)
23
+ options.fluid = DEFAULT_OPTIONS.fluid;
24
+ if (options.muted === undefined)
25
+ options.muted = DEFAULT_OPTIONS.muted;
26
+ if (options.height === undefined)
27
+ options.height = DEFAULT_OPTIONS.height;
28
+ if (options.width === undefined)
29
+ options.width = DEFAULT_OPTIONS.width;
30
+ const [tracks, setTracks] = useState([]);
31
+ useEffect(() => {
32
+ const getTracks = async () => {
33
+ const newTracks = [];
34
+ for (const [i, s] of options.tracks.entries()) {
35
+ let src = s.src;
36
+ if (s.memeType == "text/srt") {
37
+ src = await convertSRTtoVTT(s.src);
38
+ }
39
+ newTracks.push(Object.assign(Object.assign({}, s), { src }));
40
+ }
41
+ setTracks(newTracks);
42
+ };
43
+ getTracks();
44
+ }, [options.tracks]);
45
+ const id = (Date.now() + Math.random() * 100).toString();
46
+ return (React.createElement(VideoPlayerComponent, { id: id, chapters: chapters, options: Object.assign(Object.assign({}, options), { tracks }), notes: notes, startTime: startTime, handleSaveNoteAction: handleSaveNoteAction, onPause: onPause, onPlay: onPlay }));
47
+ };
48
+ const SoftBuildersVideoPlayer = memo(Component, (prevProps, nextProps) => {
49
+ return (prevProps.options === nextProps.options &&
50
+ prevProps.notes === nextProps.notes &&
51
+ prevProps.chapters === nextProps.chapters &&
52
+ prevProps.startTime === nextProps.startTime);
53
+ });
54
+ export default SoftBuildersVideoPlayer;
55
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/SoftBuildersVideoPlayer/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACzD,OAAO,oBAAoB,MAAM,yBAAyB,CAAC;AAO3D,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,MAAM,eAAe,GAAmC;IACtD,QAAQ,EAAE,KAAK;IACf,QAAQ,EAAE,IAAI;IACd,KAAK,EAAE,IAAI;IACX,KAAK,EAAE,IAAI;IACX,MAAM,EAAE,GAAG;IACX,KAAK,EAAE,GAAG;IACV,OAAO,EAAE,EAAE;IACX,MAAM,EAAE,EAAE;CACX,CAAC;AAYF,MAAM,SAAS,GAAG,CAAK,EACrB,OAAO,EACP,KAAK,EACL,QAAQ,EACR,SAAS,GAAG,CAAC,EACb,oBAAoB,EACpB,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rC,CAAC;gBAED,SAAS,CAAC,IAAI,iCACT,CAAC,KACJ,GAAG,IACH,CAAC;YACL,CAAC;YAED,SAAS,CAAC,SAAS,CAAC,CAAC;QACvB,CAAC,CAAC;QAEF,SAAS,EAAE,CAAC;IACd,CAAC,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;IAErB,MAAM,EAAE,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC;IAEzD,OAAO,CACL,oBAAC,oBAAoB,IACnB,EAAE,EAAE,EAAE,EACN,QAAQ,EAAE,QAAQ,EAClB,OAAO,kCAAO,OAAO,KAAE,MAAM,KAC7B,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,SAAS,EACpB,oBAAoB,EAAE,oBAAoB,EAC1C,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,GACd,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,uBAAuB,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,EAAE;IACvE,OAAO,CACL,SAAS,CAAC,OAAO,KAAK,SAAS,CAAC,OAAO;QACvC,SAAS,CAAC,KAAK,KAAK,SAAS,CAAC,KAAK;QACnC,SAAS,CAAC,QAAQ,KAAK,SAAS,CAAC,QAAQ;QACzC,SAAS,CAAC,SAAS,KAAK,SAAS,CAAC,SAAS,CAC5C,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,eAAe,uBAAuB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ type SubtitleMenuProps = {};
3
+ declare const SubtitleMenu: ({}: SubtitleMenuProps) => React.JSX.Element;
4
+ export default SubtitleMenu;
@@ -0,0 +1,54 @@
1
+ import React, { useEffect, useState } from "react";
2
+ import MenuButton from "../MenuButton";
3
+ import { useSoftBuildersVideoPlayerContext } from "../VideoPlayerComponent/provider";
4
+ import { CheckedIcon, LeftArrowIcon, SubtitlesIcon, } from "../../icons";
5
+ const SubtitleOption = ({ isSelected, subtitle, onClick, }) => {
6
+ return (React.createElement("button", { className: "hover:sb-text-orange-500 sb-p-2", onClick: onClick },
7
+ React.createElement("div", { className: "sb-grid sb-grid-cols-12 sb-items-center sb-gap-2" },
8
+ React.createElement("div", { className: "sb-col-span-3" }, isSelected ? React.createElement(CheckedIcon, { className: "sb-w-5 sb-h-5" }) : React.createElement("div", null)),
9
+ React.createElement("p", { className: "sb-text-left sb-col-span-9" }, subtitle.label))));
10
+ };
11
+ const SubtitleMenu = ({}) => {
12
+ const { player } = useSoftBuildersVideoPlayerContext();
13
+ const [closeMenuFunction, setCloseMenuFunction] = useState(undefined);
14
+ const [subtitles, setSubtitles] = useState([]);
15
+ const handleSelectSubtitle = (textTrack) => {
16
+ const newSubtitles = subtitles.map((s) => {
17
+ if (s.label === textTrack.label) {
18
+ s.mode = "showing";
19
+ }
20
+ else {
21
+ s.mode = "disabled";
22
+ }
23
+ return s;
24
+ });
25
+ setSubtitles(newSubtitles);
26
+ };
27
+ useEffect(() => {
28
+ var _a;
29
+ if (player) {
30
+ const textTracks = (_a = player.textTracks()) === null || _a === void 0 ? void 0 : _a.tracks_;
31
+ setSubtitles(textTracks);
32
+ }
33
+ }, [player]);
34
+ return (React.createElement(MenuButton, { buttonContent: React.createElement(SubtitlesIcon, { className: "sb-w-3 sb-h-3" }), menuContent: React.createElement("div", { className: "sb-rounded-md sb-bg-[#303030] sb-bg-opacity-50 sb-py-5 sb-w-[150px]" },
35
+ React.createElement("div", { className: "sb-flex sb-flex-col sb-gap-3" },
36
+ React.createElement("div", { className: "sb-px-5 sb-flex sb-flex-row sb-gap-3 sb-items-start" },
37
+ React.createElement("button", { onClick: () => {
38
+ if (closeMenuFunction) {
39
+ closeMenuFunction();
40
+ }
41
+ }, className: "hover:sb-scale-150" },
42
+ React.createElement(LeftArrowIcon, { className: "sb-w-3 sb-h-3" })),
43
+ React.createElement("h3", null, "Subtitle")),
44
+ React.createElement("div", { className: "sb-w-full sb-h-[.1px] sb-bg-[#AAAAAA] sb-bg-opacity-70" }),
45
+ React.createElement("div", { className: "sb-px-5 sb-flex sb-flex-col sb-gap-3 sb-items-start" }, subtitles.map((q, i) => {
46
+ return (React.createElement(SubtitleOption, { key: `subtitle-${q.label}-${i}`, isSelected: q.mode === "showing", subtitle: q, onClick: () => {
47
+ handleSelectSubtitle(q);
48
+ } }));
49
+ })))), close: (fn) => {
50
+ setCloseMenuFunction(() => fn);
51
+ } }));
52
+ };
53
+ export default SubtitleMenu;
54
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/SubtitleMenu/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAe,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAChE,OAAO,UAAU,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,iCAAiC,EAAE,MAAM,kCAAkC,CAAC;AAErF,OAAO,EACL,WAAW,EACX,aAAa,EACb,aAAa,GACd,MAAM,aAAa,CAAC;AAOrB,MAAM,cAAc,GAAG,CAAC,EACtB,UAAU,EACV,QAAQ,EACR,OAAO,GACa,EAAE,EAAE;IACxB,OAAO,CACL,gCAAQ,SAAS,EAAC,iCAAiC,EAAC,OAAO,EAAE,OAAO;QAClE,6BAAK,SAAS,EAAC,kDAAkD;YAC/D,6BAAK,SAAS,EAAC,eAAe,IAC3B,UAAU,CAAC,CAAC,CAAC,oBAAC,WAAW,IAAC,SAAS,EAAC,eAAe,GAAG,CAAC,CAAC,CAAC,gCAAW,CACjE;YAEN,2BAAG,SAAS,EAAC,4BAA4B,IAAE,QAAQ,CAAC,KAAK,CAAK,CAC1D,CACC,CACV,CAAC;AACJ,CAAC,CAAC;AAIF,MAAM,YAAY,GAAG,CAAC,EAAqB,EAAE,EAAE;IAC7C,MAAM,EAAE,MAAM,EAAE,GAAG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,GAAG,CACpC;oBACT,2CAAiB,CACb;gBAEN,6BAAK,SAAS,EAAC,wDAAwD,GAAG;gBAE1E,6BAAK,SAAS,EAAC,sDAAsD,IAClE,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;oBACtB,OAAO,CACL,oBAAC,cAAc,IACb,GAAG,EAAE,YAAY,CAAC,CAAC,KAAK,IAAI,CAAC,EAAE,EAC/B,UAAU,EAAE,CAAC,CAAC,IAAI,KAAK,SAAS,EAChC,QAAQ,EAAE,CAAC,EACX,OAAO,EAAE,GAAG,EAAE;4BACZ,oBAAoB,CAAC,CAAC,CAAC,CAAC;wBAC1B,CAAC,GACD,CACH,CAAC;gBACJ,CAAC,CAAC,CACE,CACF,CACF,EAER,KAAK,EAAE,CAAC,EAAY,EAAE,EAAE;YACtB,oBAAoB,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC;QACjC,CAAC,GACD,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -0,0 +1,7 @@
1
+ import React from "react";
2
+ import { SoftBuildersVideoPlayerChapter } from "../../types";
3
+ type Props = {
4
+ chapters: SoftBuildersVideoPlayerChapter[];
5
+ };
6
+ declare const TimeSlider: ({ chapters }: Props) => React.JSX.Element;
7
+ export default TimeSlider;
@@ -0,0 +1,69 @@
1
+ import React, { useEffect, useState } from "react";
2
+ import Slider from "../Slider";
3
+ import { useSoftBuildersVideoPlayerContext } from "../VideoPlayerComponent/provider";
4
+ const MIN = 0, MAX = 100;
5
+ const DEFERENCE = Math.abs(MAX - MIN);
6
+ const BAR_PERCENTAGE_WIDTH = 0.5;
7
+ const TimeSlider = ({ chapters }) => {
8
+ const [timeSlider, setTimeSlider] = useState(0);
9
+ const { player, duration, downloadedBufferPercentage } = useSoftBuildersVideoPlayerContext();
10
+ const handleValueChange = (e) => {
11
+ const newTimeSlider = Number(e.target.value);
12
+ setTimeSlider(newTimeSlider);
13
+ const time = (newTimeSlider * duration) / DEFERENCE;
14
+ player === null || player === void 0 ? void 0 : player.currentTime(time);
15
+ };
16
+ useEffect(() => {
17
+ const intervalId = setInterval(() => {
18
+ const currentTime = (player === null || player === void 0 ? void 0 : player.currentTime()) || 0;
19
+ const time = (currentTime * DEFERENCE) / duration;
20
+ setTimeSlider(time);
21
+ }, 1000);
22
+ // Cleanup function to clear the interval
23
+ return () => clearInterval(intervalId);
24
+ }, [player, duration]);
25
+ const [maskCuttes, setMaskCuttes] = useState("");
26
+ useEffect(() => {
27
+ const arr = ["black 0%"];
28
+ chapters.forEach((c) => {
29
+ const startPercentage = Math.floor((c.startTime * 100) / duration);
30
+ const endPercentage = Math.floor((c.endTime * 100) / duration);
31
+ arr.push(`black ${startPercentage}%`);
32
+ arr.push(`transparent ${startPercentage}%`);
33
+ arr.push(`transparent ${startPercentage + BAR_PERCENTAGE_WIDTH}%`);
34
+ arr.push(`black ${startPercentage + BAR_PERCENTAGE_WIDTH}%`);
35
+ arr.push(`black ${endPercentage}%`);
36
+ arr.push(`transparent ${endPercentage}%`);
37
+ arr.push(`transparent ${endPercentage + BAR_PERCENTAGE_WIDTH}%`);
38
+ arr.push(`black ${endPercentage + BAR_PERCENTAGE_WIDTH}%`);
39
+ });
40
+ arr.push(`black 100%`);
41
+ setMaskCuttes(arr.toString());
42
+ }, [chapters, duration]);
43
+ return (React.createElement("div", { className: " sb-w-full sb-h-2 sb-flex sb-items-center sb-justify-center" },
44
+ React.createElement("div", { className: "sb-absolute sb-top-0 sb-left-0 sb-w-full sb-z-10" },
45
+ React.createElement(Slider, { value: timeSlider, handleValueChange: handleValueChange, min: MIN, max: MAX, style: {
46
+ background: "transparent",
47
+ } })),
48
+ React.createElement("div", { className: "sb-absolute sb-top-0 sb-left-0 sb-w-full sb-h-2 sb-bg-slate-400 sb-rounded-md", style: {
49
+ background: `
50
+ linear-gradient(to right,
51
+ #f97316 0%,
52
+ #f97316 ${timeSlider}%,
53
+ #f9731640 ${timeSlider}%,
54
+ #f9731640 ${downloadedBufferPercentage}%,
55
+ #30303030 ${timeSlider}%,
56
+ #30303030 100%
57
+ )
58
+ `,
59
+ maskImage: `
60
+ linear-gradient(to right,
61
+ ${maskCuttes}
62
+ )
63
+ `,
64
+ maskSize: "100% 100%",
65
+ maskRepeat: "no-repeat",
66
+ } })));
67
+ };
68
+ export default TimeSlider;
69
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/TimeSlider/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACnD,OAAO,MAAM,MAAM,WAAW,CAAC;AAC/B,OAAO,EAAE,iCAAiC,EAAE,MAAM,kCAAkC,CAAC;AAGrF,MAAM,GAAG,GAAG,CAAC,EACX,GAAG,GAAG,GAAG,CAAC;AACZ,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC;AACtC,MAAM,oBAAoB,GAAG,GAAG,CAAC;AAMjC,MAAM,UAAU,GAAG,CAAC,EAAE,QAAQ,EAAS,EAAE,EAAE;IACzC,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IAEhD,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,0BAA0B,EAAE,GACpD,iCAAiC,EAAE,CAAC;IAEtC,MAAM,iBAAiB,GAAG,CAAC,CAAsC,EAAE,EAAE;QACnE,MAAM,aAAa,GAAG,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC7C,aAAa,CAAC,aAAa,CAAC,CAAC;QAE7B,MAAM,IAAI,GAAG,CAAC,aAAa,GAAG,QAAQ,CAAC,GAAG,SAAS,CAAC;QAEpD,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,WAAW,CAAC,IAAI,CAAC,CAAC;IAC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,GAAG,CAAC,CAAC;YAEpC,GAAG,CAAC,IAAI,CAAC,eAAe,aAAa,GAAG,CAAC,CAAC;YAC1C,GAAG,CAAC,IAAI,CAAC,eAAe,aAAa,GAAG,oBAAoB,GAAG,CAAC,CAAC;YAEjE,GAAG,CAAC,IAAI,CAAC,SAAS,aAAa,GAAG,oBAAoB,GAAG,CAAC,CAAC;QAC7D,CAAC,CAAC,CAAC;QACH,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAEvB,aAAa,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;IAChC,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC;IAEzB,OAAO,CACL,6BAAK,SAAS,EAAC,6DAA6D;QAC1E,6BAAK,SAAS,EAAC,kDAAkD;YAC/D,oBAAC,MAAM,IACL,KAAK,EAAE,UAAU,EACjB,iBAAiB,EAAE,iBAAiB,EACpC,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,GAAG,EACR,KAAK,EAAE;oBACL,UAAU,EAAE,aAAa;iBAC1B,GACD,CACE;QAEN,6BACE,SAAS,EAAC,+EAA+E,EACzF,KAAK,EAAE;gBACL,UAAU,EAAE;;;sBAGA,UAAU;wBACR,UAAU;wBACV,0BAA0B;wBAC1B,UAAU;;;SAGzB;gBACC,SAAS,EAAE;;cAEP,UAAU;;SAEf;gBACC,QAAQ,EAAE,WAAW;gBACrB,UAAU,EAAE,WAAW;aACxB,GACI,CACH,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -0,0 +1,8 @@
1
+ import React from "react";
2
+ import { SoftBuildersVideoPlayerChapter, SoftBuildersVideoPlayerNote } from "../../types";
3
+ type Props = {
4
+ notes: SoftBuildersVideoPlayerNote[];
5
+ chapters: SoftBuildersVideoPlayerChapter[];
6
+ };
7
+ declare const TimeSliderContainer: ({ notes, chapters }: Props) => React.JSX.Element;
8
+ export default TimeSliderContainer;
@@ -0,0 +1,14 @@
1
+ import React from "react";
2
+ import NotesPanal from "../NotesPanal";
3
+ import ChaptersPanal from "../ChaptersPanal";
4
+ import TimeSlider from "../TimeSlider";
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 })));
12
+ };
13
+ export default TimeSliderContainer;
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +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"}
@@ -0,0 +1,7 @@
1
+ import React from "react";
2
+ type Props = {
3
+ open: boolean;
4
+ children: React.ReactNode;
5
+ };
6
+ declare const Tooltip: ({ open, children }: Props) => React.JSX.Element;
7
+ export default Tooltip;
@@ -0,0 +1,8 @@
1
+ import React from "react";
2
+ const Tooltip = ({ open, children }) => {
3
+ if (!open)
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));
6
+ };
7
+ export default Tooltip;
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +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"}
@@ -0,0 +1,17 @@
1
+ import React from "react";
2
+ import "video.js/dist/video-js.css";
3
+ import { SoftBuildersVideoPlayerChapter, SoftBuildersVideoPlayerNote, SoftBuildersVideoPlayerOptions } from "../../types";
4
+ import "./style/style.css";
5
+ import "../../styles/tailwind.css";
6
+ export type Props<T = any> = {
7
+ id: string;
8
+ options: SoftBuildersVideoPlayerOptions;
9
+ notes: SoftBuildersVideoPlayerNote[];
10
+ chapters: SoftBuildersVideoPlayerChapter[];
11
+ startTime?: number;
12
+ handleSaveNoteAction?: (time: number, note: string) => Promise<T>;
13
+ onPlay?: (time: number) => void;
14
+ onPause?: (time: number) => void;
15
+ };
16
+ declare const VideoPlayerComponent: <T>({ id, options, notes, chapters, startTime, handleSaveNoteAction, onPlay, onPause, }: Props<T>) => React.JSX.Element;
17
+ export default VideoPlayerComponent;
@@ -0,0 +1,140 @@
1
+ import React, { useEffect, useRef, useState } from "react";
2
+ import ReactDOM from "react-dom/client";
3
+ import videojs from "video.js";
4
+ import "video.js/dist/video-js.css";
5
+ import ControlBar from "../ControlBar";
6
+ import "./style/style.css";
7
+ import "../../styles/tailwind.css";
8
+ import { SoftBuildersVideoPlayerProvider } from "./provider";
9
+ import BigPlayButton from "../BigPlayButton";
10
+ let bigPlayButtonRoot = {};
11
+ const renderBigPlayButton = (id, player, isPaused, setIsPaused) => {
12
+ const container = document.getElementById(`video-container-${id}`);
13
+ if (container) {
14
+ const element = container.querySelector(".vjs-big-play-button");
15
+ if (element) {
16
+ if (!bigPlayButtonRoot[id]) {
17
+ // If bigPlayButtonRoot hasn't been created, create it
18
+ bigPlayButtonRoot[id] = ReactDOM.createRoot(element);
19
+ }
20
+ bigPlayButtonRoot[id].render(React.createElement(BigPlayButton, { player: player, isPaused: isPaused, setIsPaused: setIsPaused }));
21
+ }
22
+ }
23
+ };
24
+ let controlBarRoot = {};
25
+ const renderControlBar = (id, player, isPaused, setIsPaused, duration, notes, chapters, seekStep = 5, handleSaveNoteAction) => {
26
+ const container = document.getElementById(`video-container-${id}`);
27
+ if (container) {
28
+ const element = container.querySelector(".vjs-control-bar");
29
+ if (element) {
30
+ if (!controlBarRoot[id]) {
31
+ // If controlBarRoot hasn't been created, create it
32
+ controlBarRoot[id] = ReactDOM.createRoot(element);
33
+ }
34
+ 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 })));
37
+ }
38
+ }
39
+ };
40
+ const VideoPlayerComponent = ({ id, options, notes, chapters, startTime = 0, handleSaveNoteAction, onPlay, onPause, }) => {
41
+ const videoRef = useRef(undefined);
42
+ const playerRef = useRef(undefined);
43
+ const [isReady, setIsReady] = useState(false);
44
+ const [isPaused, setIsPaused] = useState(!options.autoplay);
45
+ const [duration, setDuratoin] = useState(1);
46
+ const onReady = (player) => {
47
+ playerRef.current = player;
48
+ setIsReady(true);
49
+ player.currentTime(startTime);
50
+ player.on("waiting", () => { });
51
+ player.on("dispose", () => {
52
+ videojs.log("player will dispose");
53
+ setIsReady(false);
54
+ });
55
+ player.on("loadedmetadata", () => {
56
+ const d = player.duration();
57
+ setDuratoin(d);
58
+ });
59
+ };
60
+ useEffect(() => {
61
+ if (!playerRef.current) {
62
+ const videoElement = document.createElement("video-js");
63
+ videoElement.classList.add("vjs-big-play-centered");
64
+ videoRef.current.appendChild(videoElement);
65
+ playerRef.current = videojs(videoElement, options, () => {
66
+ onReady(playerRef.current);
67
+ });
68
+ }
69
+ return () => {
70
+ if (playerRef.current) {
71
+ // Dispose of the player properly on component unmount
72
+ playerRef.current.dispose();
73
+ playerRef.current = undefined;
74
+ // Defer unmounting of big play button and control bar to avoid race conditions
75
+ setTimeout(() => {
76
+ if (bigPlayButtonRoot[id]) {
77
+ bigPlayButtonRoot[id].unmount();
78
+ bigPlayButtonRoot[id] = undefined;
79
+ }
80
+ if (controlBarRoot[id]) {
81
+ controlBarRoot[id].unmount();
82
+ controlBarRoot[id] = undefined;
83
+ }
84
+ }, 0);
85
+ }
86
+ };
87
+ }, [options]);
88
+ useEffect(() => {
89
+ if (playerRef && (playerRef === null || playerRef === void 0 ? void 0 : playerRef.current) && isReady) {
90
+ const currentTime = playerRef.current.currentTime() || 0;
91
+ if (isPaused) {
92
+ if (onPause)
93
+ onPause(currentTime);
94
+ }
95
+ else {
96
+ if (onPlay)
97
+ onPlay(currentTime);
98
+ }
99
+ }
100
+ }, [isPaused, isReady]);
101
+ useEffect(() => {
102
+ if (isReady) {
103
+ const controlBarTimeout = setTimeout(() => {
104
+ renderControlBar(id, playerRef.current, isPaused, setIsPaused, duration, notes, chapters, 5, handleSaveNoteAction);
105
+ }, 500);
106
+ return () => clearTimeout(controlBarTimeout); // Clean up the timeout
107
+ }
108
+ }, [
109
+ id,
110
+ playerRef,
111
+ isPaused,
112
+ setIsPaused,
113
+ notes,
114
+ chapters,
115
+ isReady,
116
+ handleSaveNoteAction,
117
+ duration,
118
+ ]);
119
+ useEffect(() => {
120
+ if (isReady) {
121
+ const playButtonTimeout = setTimeout(() => {
122
+ renderBigPlayButton(id, playerRef.current, isPaused, setIsPaused);
123
+ }, 500);
124
+ return () => clearTimeout(playButtonTimeout); // Clean up the timeout
125
+ }
126
+ }, [id, isPaused, isReady]);
127
+ useEffect(() => {
128
+ if (playerRef.current) {
129
+ const intervalId = setInterval(() => {
130
+ setIsPaused(playerRef.current.paused());
131
+ }, 500);
132
+ return () => clearInterval(intervalId);
133
+ }
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 }))));
138
+ };
139
+ export default VideoPlayerComponent;
140
+ //# sourceMappingURL=index.js.map
@@ -0,0 +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,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E;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,6BACE,EAAE,EAAE,mBAAmB,EAAE,EAAE,EAC3B,SAAS,EAAC,8CAA8C;QAExD;YACE,6BAAK,GAAG,EAAE,QAAQ,GAAI,CAClB,CACF,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
@@ -0,0 +1,18 @@
1
+ import React, { ReactNode } from "react";
2
+ import Player from "video.js/dist/types/player";
3
+ interface SoftBuildersVideoPlayerContextType {
4
+ player: Player | undefined;
5
+ setPlayer: React.Dispatch<React.SetStateAction<Player | undefined>>;
6
+ currentTime: number;
7
+ setCurrentTime: (value: number) => void;
8
+ duration: number;
9
+ setDuration: React.Dispatch<React.SetStateAction<number>>;
10
+ downloadedBufferPercentage: number;
11
+ downloadedBufferTime: number;
12
+ setDownloadedBufferTimeufferTime: React.Dispatch<React.SetStateAction<number>>;
13
+ }
14
+ export declare const SoftBuildersVideoPlayerProvider: ({ children, }: {
15
+ children: ReactNode;
16
+ }) => React.JSX.Element;
17
+ export declare const useSoftBuildersVideoPlayerContext: () => SoftBuildersVideoPlayerContextType;
18
+ export {};
@@ -0,0 +1,36 @@
1
+ import React, { createContext, useContext, useState, useEffect, } from "react";
2
+ const SoftBuildersVideoPlayerContext = createContext(undefined);
3
+ // Create a provider component
4
+ export const SoftBuildersVideoPlayerProvider = ({ children, }) => {
5
+ const [player, setPlayer] = useState(undefined);
6
+ const [currentTime, setCurrentTime] = useState(0);
7
+ const [duration, setDuration] = useState(1);
8
+ // const [isPaused, setIsPaused] = useState(false);
9
+ const [downloadedBufferTime, setDownloadedBufferTimeufferTime] = useState(0);
10
+ const [downloadedBufferPercentage, setDownloadedBufferPercentage] = useState(0);
11
+ useEffect(() => {
12
+ setDownloadedBufferPercentage((downloadedBufferTime * 100) / duration);
13
+ }, [downloadedBufferTime]);
14
+ return (React.createElement(SoftBuildersVideoPlayerContext.Provider, { value: {
15
+ player,
16
+ setPlayer,
17
+ duration,
18
+ setDuration,
19
+ currentTime,
20
+ setCurrentTime: (value) => setCurrentTime(Math.floor(value)),
21
+ // isPaused,
22
+ // setIsPaused,
23
+ downloadedBufferTime,
24
+ setDownloadedBufferTimeufferTime,
25
+ downloadedBufferPercentage,
26
+ } }, children));
27
+ };
28
+ // Custom hook to use the context
29
+ export const useSoftBuildersVideoPlayerContext = () => {
30
+ const context = useContext(SoftBuildersVideoPlayerContext);
31
+ if (!context) {
32
+ throw new Error("useSoftBuildersVideoPlayerContext must be used within an SoftBuildersVideoPlayerProvider");
33
+ }
34
+ return context;
35
+ };
36
+ //# sourceMappingURL=provider.js.map