softbuilders-react-video-player 1.1.8 → 1.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +126 -126
- package/dist/components/BigPlayButton/index.js +1 -1
- package/dist/components/BigPlayButton/index.js.map +1 -1
- package/dist/components/BigPlayButton/index.tsx +33 -31
- package/dist/components/BufferTracker/index.tsx +19 -19
- package/dist/components/ChapterTooltip/index.tsx +65 -65
- package/dist/components/ChaptersPanal/index.tsx +40 -40
- package/dist/components/ControlBar/index.d.ts +2 -1
- package/dist/components/ControlBar/index.js +21 -6
- package/dist/components/ControlBar/index.js.map +1 -1
- package/dist/components/ControlBar/index.tsx +150 -127
- package/dist/components/CreateNoteMenu/index.tsx +61 -61
- package/dist/components/CurrentTimeLabel/index.tsx +13 -13
- package/dist/components/CurrentTimeTracker/index.tsx +18 -18
- package/dist/components/Menu/index.tsx +49 -49
- package/dist/components/MenuButton/index.js +1 -1
- package/dist/components/MenuButton/index.js.map +1 -1
- package/dist/components/MenuButton/index.tsx +67 -67
- package/dist/components/NoteTooltip/index.tsx +46 -46
- package/dist/components/NotesPanal/index.tsx +34 -34
- package/dist/components/QualityMenu/index.js +2 -2
- package/dist/components/QualityMenu/index.js.map +1 -1
- package/dist/components/QualityMenu/index.tsx +122 -122
- package/dist/components/Slider/index.d.ts +1 -1
- package/dist/components/Slider/index.js +3 -3
- package/dist/components/Slider/index.js.map +1 -1
- package/dist/components/Slider/index.tsx +36 -37
- package/dist/components/Slider/style.css +49 -15
- package/dist/components/SoftBuildersVideoPlayer/index.js +1 -1
- package/dist/components/SoftBuildersVideoPlayer/index.js.map +1 -1
- package/dist/components/SoftBuildersVideoPlayer/index.tsx +110 -109
- package/dist/components/SubtitleMenu/index.js +2 -2
- package/dist/components/SubtitleMenu/index.js.map +1 -1
- package/dist/components/SubtitleMenu/index.tsx +107 -108
- package/dist/components/TimeSlider/index.js +13 -13
- package/dist/components/TimeSlider/index.tsx +107 -107
- package/dist/components/TimeSliderContainer/index.tsx +35 -35
- package/dist/components/Tooltip/index.tsx +16 -16
- package/dist/components/VideoPlayerComponent/index.d.ts +2 -1
- package/dist/components/VideoPlayerComponent/index.js +54 -38
- package/dist/components/VideoPlayerComponent/index.js.map +1 -1
- package/dist/components/VideoPlayerComponent/index.tsx +271 -249
- package/dist/components/VideoPlayerComponent/provider.tsx +82 -82
- package/dist/components/VideoPlayerComponent/style/style.css +36 -36
- package/dist/components/VolumeSlider/index.d.ts +4 -2
- package/dist/components/VolumeSlider/index.js +12 -2
- package/dist/components/VolumeSlider/index.js.map +1 -1
- package/dist/components/VolumeSlider/index.tsx +91 -52
- package/dist/components/icons/SubIcon.d.ts +3 -0
- package/dist/components/icons/SubIcon.js +4 -0
- package/dist/components/icons/SubIcon.js.map +1 -0
- package/dist/components/icons/SubIcon.tsx +28 -0
- package/dist/components/icons/index.d.ts +1 -0
- package/dist/components/icons/index.js +1 -0
- package/dist/components/icons/index.js.map +1 -1
- package/dist/components/icons/index.ts +15 -14
- package/dist/images/index.d.ts +1 -0
- package/dist/images/index.js +1 -0
- package/dist/images/index.js.map +1 -1
- package/dist/index.css +78 -3
- package/dist/index.mjs +276 -169
- package/dist/styles/tailwind.css +140 -87
- package/package.json +45 -45
@@ -1,37 +1,36 @@
|
|
1
|
-
import React, { InputHTMLAttributes, SetStateAction, useState } from "react";
|
2
|
-
import "./style.css";
|
3
|
-
|
4
|
-
type Props = {
|
5
|
-
value: number;
|
6
|
-
handleValueChange: React.ChangeEventHandler<HTMLInputElement>;
|
7
|
-
min?: number;
|
8
|
-
max?: number;
|
9
|
-
} & InputHTMLAttributes<HTMLInputElement>;
|
10
|
-
|
11
|
-
const Slider = ({
|
12
|
-
value,
|
13
|
-
handleValueChange,
|
14
|
-
min = 0,
|
15
|
-
max = 100,
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
}
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
export default Slider;
|
1
|
+
import React, { InputHTMLAttributes, SetStateAction, useState } from "react";
|
2
|
+
import "./style.css";
|
3
|
+
|
4
|
+
type Props = {
|
5
|
+
value: number;
|
6
|
+
handleValueChange: React.ChangeEventHandler<HTMLInputElement>;
|
7
|
+
min?: number;
|
8
|
+
max?: number;
|
9
|
+
} & InputHTMLAttributes<HTMLInputElement>;
|
10
|
+
|
11
|
+
const Slider = ({
|
12
|
+
value,
|
13
|
+
handleValueChange,
|
14
|
+
min = 0,
|
15
|
+
max = 100,
|
16
|
+
className,
|
17
|
+
...rest
|
18
|
+
}: Props) => {
|
19
|
+
return (
|
20
|
+
<input
|
21
|
+
type="range"
|
22
|
+
min={min}
|
23
|
+
max={max}
|
24
|
+
value={value}
|
25
|
+
onChange={handleValueChange}
|
26
|
+
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
|
27
|
+
${className}`}
|
28
|
+
style={{
|
29
|
+
background: `linear-gradient(to right, #f97316 ${value}%, #30303070 ${value}%)`,
|
30
|
+
}}
|
31
|
+
{...rest}
|
32
|
+
/>
|
33
|
+
);
|
34
|
+
};
|
35
|
+
|
36
|
+
export default Slider;
|
@@ -1,15 +1,49 @@
|
|
1
|
-
/* Styling the slider track */
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
1
|
+
/* Styling the slider track */
|
2
|
+
|
3
|
+
|
4
|
+
input[type="range"]::-webkit-slider-thumb {
|
5
|
+
-webkit-appearance: none;
|
6
|
+
appearance: none;
|
7
|
+
width: 20px;
|
8
|
+
height: 20px;
|
9
|
+
border-radius: 50%;
|
10
|
+
background: white;
|
11
|
+
cursor: pointer;
|
12
|
+
}
|
13
|
+
|
14
|
+
input[type="range"]:focus {
|
15
|
+
outline: none;
|
16
|
+
}
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
/* Custom slider knob (thumb) for Chrome/Safari */
|
22
|
+
input[type="range"]::-webkit-slider-thumb {
|
23
|
+
width: 0.95rem;
|
24
|
+
height: 0.95rem;
|
25
|
+
border-radius: 50%; /* Make it a circle */
|
26
|
+
cursor: pointer;
|
27
|
+
}
|
28
|
+
|
29
|
+
/* Custom slider knob (thumb) for Firefox */
|
30
|
+
input[type="range"]::-moz-range-thumb {
|
31
|
+
width: 0.95rem;
|
32
|
+
height: 0.95rem;
|
33
|
+
border-radius: 50%; /* Make it a circle */
|
34
|
+
cursor: pointer;
|
35
|
+
}
|
36
|
+
|
37
|
+
/* Media query for screens below medium (md) */
|
38
|
+
@media (max-width: 768px) { /* Adjust the max-width value to match your md breakpoint */
|
39
|
+
input[type="range"]::-webkit-slider-thumb {
|
40
|
+
width: 0.7rem; /* Smaller thumb size */
|
41
|
+
height: 0.7rem; /* Smaller thumb size */
|
42
|
+
}
|
43
|
+
|
44
|
+
input[type="range"]::-moz-range-thumb {
|
45
|
+
width: 0.7rem; /* Smaller thumb size */
|
46
|
+
height: 0.7rem; /* Smaller thumb size */
|
47
|
+
}
|
48
|
+
}
|
49
|
+
|
@@ -45,7 +45,7 @@ const Component = ({ options, notes, chapters, startTime = 0, handleSaveNoteActi
|
|
45
45
|
getTracks();
|
46
46
|
}, [options.tracks]);
|
47
47
|
const id = (Date.now() + Math.random() * 100).toString();
|
48
|
-
return (_jsx(VideoPlayerComponent, { id: id, chapters: chapters, options: Object.assign(Object.assign({}, options), { tracks }), notes: notes, startTime: startTime, handleSaveNoteAction: handleSaveNoteAction, onPause: onPause, onPlay: onPlay }));
|
48
|
+
return (_jsx(VideoPlayerComponent, { id: id, chapters: chapters, options: Object.assign(Object.assign({}, options), { tracks }), notes: notes, poster: "", startTime: startTime, handleSaveNoteAction: handleSaveNoteAction, onPause: onPause, onPlay: onPlay }));
|
49
49
|
};
|
50
50
|
const SoftBuildersVideoPlayer = memo(Component, (prevProps, nextProps) => {
|
51
51
|
return (prevProps.options === nextProps.options &&
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/SoftBuildersVideoPlayer/index.tsx"],"names":[],"mappings":";AAAA,OAAc,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,MAAM,EACN,OAAO,GACE,EAAE,EAAE;IACb,OAAO,GAAG,gCACL,OAAO,KACV,UAAU,EAAE,IAAI,EAChB,iBAAiB,EAAE,CAAC,EACpB,UAAU,EAAE;YACV,YAAY,EAAE,MAAM;SACrB,GACK,CAAC;IAET,IAAI,OAAO,CAAC,QAAQ,KAAK,SAAS;QAChC,OAAO,CAAC,QAAQ,GAAG,eAAe,CAAC,QAAQ,CAAC;IAC9C,IAAI,OAAO,CAAC,QAAQ,KAAK,SAAS;QAChC,OAAO,CAAC,QAAQ,GAAG,eAAe,CAAC,QAAQ,CAAC;IAC9C,IAAI,OAAO,CAAC,KAAK,KAAK,SAAS;QAAE,OAAO,CAAC,K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C,CAAC,GAAG,CAAC,CAAC;oBACrC,CAAC;oBAED,SAAS,CAAC,IAAI,iCACT,CAAC,KACJ,GAAG,IACH,CAAC;gBACL,CAAC;YAEH,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,KAAC,oBAAoB,IACnB,EAAE,EAAE,EAAE,EACN,QAAQ,EAAE,QAAQ,EAClB,OAAO,kCAAO,OAAO,KAAE,MAAM,KAC7B,KAAK,EAAE,KAAK,EACZ,MAAM,EAAC,EAAE,EACT,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"}
|
@@ -1,109 +1,110 @@
|
|
1
|
-
import React, { memo, useEffect, useState } from "react";
|
2
|
-
import VideoPlayerComponent from "../VideoPlayerComponent";
|
3
|
-
import {
|
4
|
-
SoftBuildersVideoPlayerChapter,
|
5
|
-
SoftBuildersVideoPlayerNote,
|
6
|
-
SoftBuildersVideoPlayerOptions,
|
7
|
-
SoftBuildersVideoPlayerTrack,
|
8
|
-
} from "../../types";
|
9
|
-
import { convertSRTtoVTT } from "../../utils";
|
10
|
-
|
11
|
-
const DEFAULT_OPTIONS: SoftBuildersVideoPlayerOptions = {
|
12
|
-
autoplay: false,
|
13
|
-
controls: true,
|
14
|
-
fluid: true,
|
15
|
-
muted: true,
|
16
|
-
height: 420,
|
17
|
-
width: 720,
|
18
|
-
sources: [],
|
19
|
-
tracks: [],
|
20
|
-
};
|
21
|
-
|
22
|
-
export type Props<T = any> = {
|
23
|
-
options: SoftBuildersVideoPlayerOptions;
|
24
|
-
notes: SoftBuildersVideoPlayerNote[];
|
25
|
-
chapters: SoftBuildersVideoPlayerChapter[];
|
26
|
-
startTime?: number;
|
27
|
-
handleSaveNoteAction?: (time: number, note: string) => Promise<T>;
|
28
|
-
onPlay?: (time: number) => void;
|
29
|
-
onPause?: (time: number) => void;
|
30
|
-
};
|
31
|
-
|
32
|
-
const Component = <T,>({
|
33
|
-
options,
|
34
|
-
notes,
|
35
|
-
chapters,
|
36
|
-
startTime = 0,
|
37
|
-
handleSaveNoteAction,
|
38
|
-
onPlay,
|
39
|
-
onPause,
|
40
|
-
}: Props<T>) => {
|
41
|
-
options = {
|
42
|
-
...options,
|
43
|
-
responsive: true,
|
44
|
-
inactivityTimeout: 0,
|
45
|
-
fullscreen: {
|
46
|
-
navigationUI: "hide",
|
47
|
-
},
|
48
|
-
} as any;
|
49
|
-
|
50
|
-
if (options.autoplay === undefined)
|
51
|
-
options.autoplay = DEFAULT_OPTIONS.autoplay;
|
52
|
-
if (options.controls === undefined)
|
53
|
-
options.controls = DEFAULT_OPTIONS.controls;
|
54
|
-
if (options.fluid === undefined) options.fluid = DEFAULT_OPTIONS.fluid;
|
55
|
-
if (options.muted === undefined) options.muted = DEFAULT_OPTIONS.muted;
|
56
|
-
if (options.height === undefined) options.height = DEFAULT_OPTIONS.height;
|
57
|
-
if (options.width === undefined) options.width = DEFAULT_OPTIONS.width;
|
58
|
-
|
59
|
-
const [tracks, setTracks] = useState<SoftBuildersVideoPlayerTrack[]>([]);
|
60
|
-
|
61
|
-
useEffect(() => {
|
62
|
-
const getTracks = async () => {
|
63
|
-
const newTracks: SoftBuildersVideoPlayerTrack[] = [];
|
64
|
-
if (Array.isArray(options.tracks))
|
65
|
-
for (const [i, s] of options.tracks.entries()) {
|
66
|
-
let src = s.src;
|
67
|
-
|
68
|
-
if (s.memeType == "text/srt") {
|
69
|
-
src = await convertSRTtoVTT(s.src);
|
70
|
-
}
|
71
|
-
|
72
|
-
newTracks.push({
|
73
|
-
...s,
|
74
|
-
src,
|
75
|
-
});
|
76
|
-
}
|
77
|
-
|
78
|
-
setTracks(newTracks);
|
79
|
-
};
|
80
|
-
|
81
|
-
getTracks();
|
82
|
-
}, [options.tracks]);
|
83
|
-
|
84
|
-
const id = (Date.now() + Math.random() * 100).toString();
|
85
|
-
|
86
|
-
return (
|
87
|
-
<VideoPlayerComponent
|
88
|
-
id={id}
|
89
|
-
chapters={chapters}
|
90
|
-
options={{ ...options, tracks }}
|
91
|
-
notes={notes}
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
prevProps.
|
104
|
-
prevProps.
|
105
|
-
prevProps.
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
1
|
+
import React, { memo, useEffect, useState } from "react";
|
2
|
+
import VideoPlayerComponent from "../VideoPlayerComponent";
|
3
|
+
import {
|
4
|
+
SoftBuildersVideoPlayerChapter,
|
5
|
+
SoftBuildersVideoPlayerNote,
|
6
|
+
SoftBuildersVideoPlayerOptions,
|
7
|
+
SoftBuildersVideoPlayerTrack,
|
8
|
+
} from "../../types";
|
9
|
+
import { convertSRTtoVTT } from "../../utils";
|
10
|
+
|
11
|
+
const DEFAULT_OPTIONS: SoftBuildersVideoPlayerOptions = {
|
12
|
+
autoplay: false,
|
13
|
+
controls: true,
|
14
|
+
fluid: true,
|
15
|
+
muted: true,
|
16
|
+
height: 420,
|
17
|
+
width: 720,
|
18
|
+
sources: [],
|
19
|
+
tracks: [],
|
20
|
+
};
|
21
|
+
|
22
|
+
export type Props<T = any> = {
|
23
|
+
options: SoftBuildersVideoPlayerOptions;
|
24
|
+
notes: SoftBuildersVideoPlayerNote[];
|
25
|
+
chapters: SoftBuildersVideoPlayerChapter[];
|
26
|
+
startTime?: number;
|
27
|
+
handleSaveNoteAction?: (time: number, note: string) => Promise<T>;
|
28
|
+
onPlay?: (time: number) => void;
|
29
|
+
onPause?: (time: number) => void;
|
30
|
+
};
|
31
|
+
|
32
|
+
const Component = <T,>({
|
33
|
+
options,
|
34
|
+
notes,
|
35
|
+
chapters,
|
36
|
+
startTime = 0,
|
37
|
+
handleSaveNoteAction,
|
38
|
+
onPlay,
|
39
|
+
onPause,
|
40
|
+
}: Props<T>) => {
|
41
|
+
options = {
|
42
|
+
...options,
|
43
|
+
responsive: true,
|
44
|
+
inactivityTimeout: 0,
|
45
|
+
fullscreen: {
|
46
|
+
navigationUI: "hide",
|
47
|
+
},
|
48
|
+
} as any;
|
49
|
+
|
50
|
+
if (options.autoplay === undefined)
|
51
|
+
options.autoplay = DEFAULT_OPTIONS.autoplay;
|
52
|
+
if (options.controls === undefined)
|
53
|
+
options.controls = DEFAULT_OPTIONS.controls;
|
54
|
+
if (options.fluid === undefined) options.fluid = DEFAULT_OPTIONS.fluid;
|
55
|
+
if (options.muted === undefined) options.muted = DEFAULT_OPTIONS.muted;
|
56
|
+
if (options.height === undefined) options.height = DEFAULT_OPTIONS.height;
|
57
|
+
if (options.width === undefined) options.width = DEFAULT_OPTIONS.width;
|
58
|
+
|
59
|
+
const [tracks, setTracks] = useState<SoftBuildersVideoPlayerTrack[]>([]);
|
60
|
+
|
61
|
+
useEffect(() => {
|
62
|
+
const getTracks = async () => {
|
63
|
+
const newTracks: SoftBuildersVideoPlayerTrack[] = [];
|
64
|
+
if (Array.isArray(options.tracks))
|
65
|
+
for (const [i, s] of options.tracks.entries()) {
|
66
|
+
let src = s.src;
|
67
|
+
|
68
|
+
if (s.memeType == "text/srt") {
|
69
|
+
src = await convertSRTtoVTT(s.src);
|
70
|
+
}
|
71
|
+
|
72
|
+
newTracks.push({
|
73
|
+
...s,
|
74
|
+
src,
|
75
|
+
});
|
76
|
+
}
|
77
|
+
|
78
|
+
setTracks(newTracks);
|
79
|
+
};
|
80
|
+
|
81
|
+
getTracks();
|
82
|
+
}, [options.tracks]);
|
83
|
+
|
84
|
+
const id = (Date.now() + Math.random() * 100).toString();
|
85
|
+
|
86
|
+
return (
|
87
|
+
<VideoPlayerComponent
|
88
|
+
id={id}
|
89
|
+
chapters={chapters}
|
90
|
+
options={{ ...options, tracks }}
|
91
|
+
notes={notes}
|
92
|
+
poster=""
|
93
|
+
startTime={startTime}
|
94
|
+
handleSaveNoteAction={handleSaveNoteAction}
|
95
|
+
onPause={onPause}
|
96
|
+
onPlay={onPlay}
|
97
|
+
/>
|
98
|
+
);
|
99
|
+
};
|
100
|
+
|
101
|
+
const SoftBuildersVideoPlayer = memo(Component, (prevProps, nextProps) => {
|
102
|
+
return (
|
103
|
+
prevProps.options === nextProps.options &&
|
104
|
+
prevProps.notes === nextProps.notes &&
|
105
|
+
prevProps.chapters === nextProps.chapters &&
|
106
|
+
prevProps.startTime === nextProps.startTime
|
107
|
+
);
|
108
|
+
});
|
109
|
+
|
110
|
+
export default SoftBuildersVideoPlayer;
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useState } from "react";
|
3
3
|
import MenuButton from "../MenuButton";
|
4
4
|
import { useSoftBuildersVideoPlayerContext } from "../VideoPlayerComponent/provider";
|
5
|
-
import { CheckedIcon, LeftArrowIcon,
|
5
|
+
import { CheckedIcon, LeftArrowIcon, SubIcon } from "../../images";
|
6
6
|
const SubtitleOption = ({ isSelected, subtitle, onClick, }) => {
|
7
7
|
return (_jsx("button", { className: "hover:sb-text-orange-500 sb-p-2", onClick: onClick, children: _jsxs("div", { className: "sb-grid sb-grid-cols-12 sb-items-center sb-gap-2", children: [_jsx("div", { className: "sb-col-span-3", children: isSelected ? _jsx(CheckedIcon, { className: "sb-w-5 sb-h-5" }) : _jsx("div", {}) }), _jsx("p", { className: "sb-text-left sb-col-span-9", children: subtitle.label })] }) }));
|
8
8
|
};
|
@@ -29,7 +29,7 @@ const SubtitleMenu = ({}) => {
|
|
29
29
|
setSubtitles(textTracks);
|
30
30
|
}
|
31
31
|
}, [player]);
|
32
|
-
return (_jsx(MenuButton, { buttonContent: _jsx(
|
32
|
+
return (_jsx(MenuButton, { buttonContent: _jsx(SubIcon, { className: "sb-w-4 sb-h-4 sb-text-white " }), menuContent: _jsx("div", { className: "sb-rounded-md sb-bg-[#303030] sb-bg-opacity-50 sb-py-5 sb-w-[150px]", children: _jsxs("div", { className: "sb-flex sb-flex-col sb-gap-3", children: [_jsxs("div", { className: "sb-px-5 sb-flex sb-flex-row sb-gap-3 sb-items-start", children: [_jsx("button", { onClick: () => {
|
33
33
|
if (closeMenuFunction) {
|
34
34
|
closeMenuFunction();
|
35
35
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/SubtitleMenu/index.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAe,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAChE,OAAO,UAAU,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,iCAAiC,EAAE,MAAM,kCAAkC,CAAC;AACrF,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/SubtitleMenu/index.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAe,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAChE,OAAO,UAAU,MAAM,eAAe,CAAC;AACvC,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AY,CAAC"}
|
@@ -1,108 +1,107 @@
|
|
1
|
-
import React, { useCallback, useEffect, useState } from "react";
|
2
|
-
import MenuButton from "../MenuButton";
|
3
|
-
import { useSoftBuildersVideoPlayerContext } from "../VideoPlayerComponent/provider";
|
4
|
-
import { CheckedIcon, LeftArrowIcon,
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
const
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
</
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
export default SubtitleMenu;
|
1
|
+
import React, { useCallback, useEffect, useState } from "react";
|
2
|
+
import MenuButton from "../MenuButton";
|
3
|
+
import { useSoftBuildersVideoPlayerContext } from "../VideoPlayerComponent/provider";
|
4
|
+
import { CheckedIcon, LeftArrowIcon, SubIcon } from "../../images";
|
5
|
+
|
6
|
+
type SubtitleOptionProps = {
|
7
|
+
isSelected: boolean;
|
8
|
+
subtitle: TextTrack;
|
9
|
+
onClick: () => void;
|
10
|
+
};
|
11
|
+
const SubtitleOption = ({
|
12
|
+
isSelected,
|
13
|
+
subtitle,
|
14
|
+
onClick,
|
15
|
+
}: SubtitleOptionProps) => {
|
16
|
+
return (
|
17
|
+
<button className="hover:sb-text-orange-500 sb-p-2" onClick={onClick}>
|
18
|
+
<div className="sb-grid sb-grid-cols-12 sb-items-center sb-gap-2">
|
19
|
+
<div className="sb-col-span-3">
|
20
|
+
{isSelected ? <CheckedIcon className="sb-w-5 sb-h-5" /> : <div></div>}
|
21
|
+
</div>
|
22
|
+
|
23
|
+
<p className="sb-text-left sb-col-span-9">{subtitle.label}</p>
|
24
|
+
</div>
|
25
|
+
</button>
|
26
|
+
);
|
27
|
+
};
|
28
|
+
|
29
|
+
type SubtitleMenuProps = {};
|
30
|
+
|
31
|
+
const SubtitleMenu = ({}: SubtitleMenuProps) => {
|
32
|
+
const { player } = useSoftBuildersVideoPlayerContext();
|
33
|
+
|
34
|
+
const [closeMenuFunction, setCloseMenuFunction] = useState<
|
35
|
+
Function | undefined
|
36
|
+
>(undefined);
|
37
|
+
|
38
|
+
const [subtitles, setSubtitles] = useState<TextTrack[]>([]);
|
39
|
+
|
40
|
+
const handleSelectSubtitle = (textTrack: TextTrack) => {
|
41
|
+
const newSubtitles = subtitles.map((s) => {
|
42
|
+
if (s.label === textTrack.label) {
|
43
|
+
s.mode = "showing";
|
44
|
+
} else {
|
45
|
+
s.mode = "disabled";
|
46
|
+
}
|
47
|
+
return s;
|
48
|
+
});
|
49
|
+
|
50
|
+
setSubtitles(newSubtitles);
|
51
|
+
};
|
52
|
+
|
53
|
+
useEffect(() => {
|
54
|
+
if (player) {
|
55
|
+
const textTracks: TextTrack[] = (player as any).textTracks()?.tracks_;
|
56
|
+
|
57
|
+
setSubtitles(textTracks);
|
58
|
+
}
|
59
|
+
}, [player]);
|
60
|
+
|
61
|
+
return (
|
62
|
+
<MenuButton
|
63
|
+
buttonContent={<SubIcon className="sb-w-4 sb-h-4 sb-text-white " />}
|
64
|
+
menuContent={
|
65
|
+
<div className="sb-rounded-md sb-bg-[#303030] sb-bg-opacity-50 sb-py-5 sb-w-[150px]">
|
66
|
+
<div className="sb-flex sb-flex-col sb-gap-3">
|
67
|
+
<div className="sb-px-5 sb-flex sb-flex-row sb-gap-3 sb-items-start">
|
68
|
+
<button
|
69
|
+
onClick={() => {
|
70
|
+
if (closeMenuFunction) {
|
71
|
+
closeMenuFunction();
|
72
|
+
}
|
73
|
+
}}
|
74
|
+
className="hover:sb-scale-150"
|
75
|
+
>
|
76
|
+
<LeftArrowIcon className="sb-w-3 sb-h-3" />
|
77
|
+
</button>
|
78
|
+
<h3>Subtitle</h3>
|
79
|
+
</div>
|
80
|
+
|
81
|
+
<div className="sb-w-full sb-h-[.1px] sb-bg-[#AAAAAA] sb-bg-opacity-70" />
|
82
|
+
|
83
|
+
<div className="sb-px-5 sb-flex sb-flex-col sb-gap-3 sb-items-start">
|
84
|
+
{subtitles.map((q, i) => {
|
85
|
+
return (
|
86
|
+
<SubtitleOption
|
87
|
+
key={`subtitle-${q.label}-${i}`}
|
88
|
+
isSelected={q.mode === "showing"}
|
89
|
+
subtitle={q}
|
90
|
+
onClick={() => {
|
91
|
+
handleSelectSubtitle(q);
|
92
|
+
}}
|
93
|
+
/>
|
94
|
+
);
|
95
|
+
})}
|
96
|
+
</div>
|
97
|
+
</div>
|
98
|
+
</div>
|
99
|
+
}
|
100
|
+
close={(fn: Function) => {
|
101
|
+
setCloseMenuFunction(() => fn);
|
102
|
+
}}
|
103
|
+
/>
|
104
|
+
);
|
105
|
+
};
|
106
|
+
|
107
|
+
export default SubtitleMenu;
|