softbuilders-react-video-player 1.1.16 → 1.1.17
Sign up to get free protection for your applications and to get access to all the features.
- package/LICENSE +21 -21
- package/README.md +126 -126
- 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.js +1 -1
- package/dist/components/ControlBar/index.js.map +1 -1
- package/dist/components/ControlBar/index.tsx +2 -2
- 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/NoteTooltip/index.tsx +46 -46
- package/dist/components/NotesPanal/index.tsx +34 -34
- 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.js +2 -2
- package/dist/components/VideoPlayerComponent/index.js.map +1 -1
- package/dist/components/VideoPlayerComponent/index.tsx +2 -2
- package/dist/components/VideoPlayerComponent/provider.tsx +82 -82
- package/dist/components/VideoPlayerComponent/style/style.css +36 -36
- package/dist/index.mjs +1 -1
- package/dist/styles/tailwind.css +101 -101
- package/package.json +4 -4
package/LICENSE
CHANGED
@@ -1,21 +1,21 @@
|
|
1
|
-
MIT License
|
2
|
-
|
3
|
-
Copyright (c) 2024 masri-softbuilders
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
7
|
-
in the Software without restriction, including without limitation the rights
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
10
|
-
furnished to do so, subject to the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
13
|
-
copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
-
SOFTWARE.
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2024 masri-softbuilders
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
@@ -1,126 +1,126 @@
|
|
1
|
-
# Usage
|
2
|
-
|
3
|
-
## install the package
|
4
|
-
|
5
|
-
```bash
|
6
|
-
npm i softbuilders-video-player
|
7
|
-
```
|
8
|
-
|
9
|
-
## How to use
|
10
|
-
|
11
|
-
```typescript
|
12
|
-
import SoftBuildersVideoPlayer, {
|
13
|
-
SoftBuildersVideoPlayerOptions,
|
14
|
-
SoftBuildersVideoPlayerChapter,
|
15
|
-
SoftBuildersVideoPlayerNote,
|
16
|
-
} from "softbuilders-video-player";
|
17
|
-
|
18
|
-
const options: SoftBuildersVideoPlayerOptions = {
|
19
|
-
autoplay: false,
|
20
|
-
controls: true,
|
21
|
-
muted: true,
|
22
|
-
fluid: true,
|
23
|
-
poster: "http://example.com/thumbnail.png", // thumbnail preview image
|
24
|
-
height: 420,
|
25
|
-
width: 720,
|
26
|
-
sources: [
|
27
|
-
{
|
28
|
-
src: "https://upload.wikimedia.org/wikipedia/commons/transcoded/a/ab/Caminandes_3_-_Llamigos_-_Blender_Animated_Short.webm/Caminandes_3_-_Llamigos_-_Blender_Animated_Short.webm.360p.vp9.webm",
|
29
|
-
type: "video/webm",
|
30
|
-
label: "360p",
|
31
|
-
},
|
32
|
-
{
|
33
|
-
src: "https://upload.wikimedia.org/wikipedia/commons/transcoded/a/ab/Caminandes_3_-_Llamigos_-_Blender_Animated_Short.webm/Caminandes_3_-_Llamigos_-_Blender_Animated_Short.webm.1080p.vp9.webm",
|
34
|
-
type: "video/webm",
|
35
|
-
label: "1080P",
|
36
|
-
},
|
37
|
-
],
|
38
|
-
tracks: [
|
39
|
-
{
|
40
|
-
kind: "captions",
|
41
|
-
src: "https://raw.githubusercontent.com/brenopolanski/html5-video-webvtt-example/master/MIB2-subtitles-pt-BR.vtt",
|
42
|
-
srclang: "en",
|
43
|
-
label: "English",
|
44
|
-
memeType: "text/vtt", // text/vtt or text/srt
|
45
|
-
default: true,
|
46
|
-
},
|
47
|
-
{
|
48
|
-
kind: "captions",
|
49
|
-
src: "https://gist.githubusercontent.com/samdutton/ca37f3adaf4e23679957b8083e061177/raw/e19399fbccbc069a2af4266e5120ae6bad62699a/sample.vtt",
|
50
|
-
srclang: "es",
|
51
|
-
label: "Espaniol",
|
52
|
-
memeType: "text/vtt", // text/vtt or text/srt
|
53
|
-
},
|
54
|
-
], // only vtt suptitilers are supported for now
|
55
|
-
};
|
56
|
-
|
57
|
-
const initNotes: SoftBuildersVideoPlayerNote[] = [
|
58
|
-
{
|
59
|
-
time: 5,
|
60
|
-
label: "Start",
|
61
|
-
},
|
62
|
-
{
|
63
|
-
time: 30,
|
64
|
-
label: "Say Hello",
|
65
|
-
},
|
66
|
-
{
|
67
|
-
time: 69,
|
68
|
-
label: "Go deep",
|
69
|
-
},
|
70
|
-
{
|
71
|
-
time: 99,
|
72
|
-
label: "Details ...",
|
73
|
-
},
|
74
|
-
{
|
75
|
-
time: 140,
|
76
|
-
label: "End",
|
77
|
-
},
|
78
|
-
];
|
79
|
-
|
80
|
-
const initChapters: SoftBuildersVideoPlayerChapter[] = [
|
81
|
-
{
|
82
|
-
startTime: 25,
|
83
|
-
endTime: 50,
|
84
|
-
title: "01 Note: **** Important ****",
|
85
|
-
},
|
86
|
-
{
|
87
|
-
startTime: 70,
|
88
|
-
endTime: 100,
|
89
|
-
title: "02 Note: To Do",
|
90
|
-
},
|
91
|
-
{ startTime: 110, endTime: 120, title: "03 Note: DIY (Do it yourself)" },
|
92
|
-
{
|
93
|
-
startTime: 125,
|
94
|
-
endTime: 140,
|
95
|
-
title: "05 Note: Conclusion ",
|
96
|
-
},
|
97
|
-
];
|
98
|
-
|
99
|
-
const Component = () => {
|
100
|
-
const handleSaveNoteAction = (time: number, note: string) => {
|
101
|
-
return new Promise((resolve) => {
|
102
|
-
resolve(true);
|
103
|
-
});
|
104
|
-
};
|
105
|
-
|
106
|
-
const onPause = (time: number) => {
|
107
|
-
console.log(`Video has been Paused at time (${time} sec)`);
|
108
|
-
};
|
109
|
-
const onPlay = (time: number) => {
|
110
|
-
console.log(`Video has been Played at time (${time} sec)`);
|
111
|
-
};
|
112
|
-
|
113
|
-
return (
|
114
|
-
<SoftBuildersVideoPlayer
|
115
|
-
options={options}
|
116
|
-
chapters={initChapters}
|
117
|
-
notes={initNotes}
|
118
|
-
handleSaveNoteAction={handleSaveNoteAction}
|
119
|
-
onPause={onPause}
|
120
|
-
onPlay={onPlay}
|
121
|
-
/>
|
122
|
-
);
|
123
|
-
};
|
124
|
-
|
125
|
-
export default Component;
|
126
|
-
```
|
1
|
+
# Usage
|
2
|
+
|
3
|
+
## install the package
|
4
|
+
|
5
|
+
```bash
|
6
|
+
npm i softbuilders-video-player
|
7
|
+
```
|
8
|
+
|
9
|
+
## How to use
|
10
|
+
|
11
|
+
```typescript
|
12
|
+
import SoftBuildersVideoPlayer, {
|
13
|
+
SoftBuildersVideoPlayerOptions,
|
14
|
+
SoftBuildersVideoPlayerChapter,
|
15
|
+
SoftBuildersVideoPlayerNote,
|
16
|
+
} from "softbuilders-video-player";
|
17
|
+
|
18
|
+
const options: SoftBuildersVideoPlayerOptions = {
|
19
|
+
autoplay: false,
|
20
|
+
controls: true,
|
21
|
+
muted: true,
|
22
|
+
fluid: true,
|
23
|
+
poster: "http://example.com/thumbnail.png", // thumbnail preview image
|
24
|
+
height: 420,
|
25
|
+
width: 720,
|
26
|
+
sources: [
|
27
|
+
{
|
28
|
+
src: "https://upload.wikimedia.org/wikipedia/commons/transcoded/a/ab/Caminandes_3_-_Llamigos_-_Blender_Animated_Short.webm/Caminandes_3_-_Llamigos_-_Blender_Animated_Short.webm.360p.vp9.webm",
|
29
|
+
type: "video/webm",
|
30
|
+
label: "360p",
|
31
|
+
},
|
32
|
+
{
|
33
|
+
src: "https://upload.wikimedia.org/wikipedia/commons/transcoded/a/ab/Caminandes_3_-_Llamigos_-_Blender_Animated_Short.webm/Caminandes_3_-_Llamigos_-_Blender_Animated_Short.webm.1080p.vp9.webm",
|
34
|
+
type: "video/webm",
|
35
|
+
label: "1080P",
|
36
|
+
},
|
37
|
+
],
|
38
|
+
tracks: [
|
39
|
+
{
|
40
|
+
kind: "captions",
|
41
|
+
src: "https://raw.githubusercontent.com/brenopolanski/html5-video-webvtt-example/master/MIB2-subtitles-pt-BR.vtt",
|
42
|
+
srclang: "en",
|
43
|
+
label: "English",
|
44
|
+
memeType: "text/vtt", // text/vtt or text/srt
|
45
|
+
default: true,
|
46
|
+
},
|
47
|
+
{
|
48
|
+
kind: "captions",
|
49
|
+
src: "https://gist.githubusercontent.com/samdutton/ca37f3adaf4e23679957b8083e061177/raw/e19399fbccbc069a2af4266e5120ae6bad62699a/sample.vtt",
|
50
|
+
srclang: "es",
|
51
|
+
label: "Espaniol",
|
52
|
+
memeType: "text/vtt", // text/vtt or text/srt
|
53
|
+
},
|
54
|
+
], // only vtt suptitilers are supported for now
|
55
|
+
};
|
56
|
+
|
57
|
+
const initNotes: SoftBuildersVideoPlayerNote[] = [
|
58
|
+
{
|
59
|
+
time: 5,
|
60
|
+
label: "Start",
|
61
|
+
},
|
62
|
+
{
|
63
|
+
time: 30,
|
64
|
+
label: "Say Hello",
|
65
|
+
},
|
66
|
+
{
|
67
|
+
time: 69,
|
68
|
+
label: "Go deep",
|
69
|
+
},
|
70
|
+
{
|
71
|
+
time: 99,
|
72
|
+
label: "Details ...",
|
73
|
+
},
|
74
|
+
{
|
75
|
+
time: 140,
|
76
|
+
label: "End",
|
77
|
+
},
|
78
|
+
];
|
79
|
+
|
80
|
+
const initChapters: SoftBuildersVideoPlayerChapter[] = [
|
81
|
+
{
|
82
|
+
startTime: 25,
|
83
|
+
endTime: 50,
|
84
|
+
title: "01 Note: **** Important ****",
|
85
|
+
},
|
86
|
+
{
|
87
|
+
startTime: 70,
|
88
|
+
endTime: 100,
|
89
|
+
title: "02 Note: To Do",
|
90
|
+
},
|
91
|
+
{ startTime: 110, endTime: 120, title: "03 Note: DIY (Do it yourself)" },
|
92
|
+
{
|
93
|
+
startTime: 125,
|
94
|
+
endTime: 140,
|
95
|
+
title: "05 Note: Conclusion ",
|
96
|
+
},
|
97
|
+
];
|
98
|
+
|
99
|
+
const Component = () => {
|
100
|
+
const handleSaveNoteAction = (time: number, note: string) => {
|
101
|
+
return new Promise((resolve) => {
|
102
|
+
resolve(true);
|
103
|
+
});
|
104
|
+
};
|
105
|
+
|
106
|
+
const onPause = (time: number) => {
|
107
|
+
console.log(`Video has been Paused at time (${time} sec)`);
|
108
|
+
};
|
109
|
+
const onPlay = (time: number) => {
|
110
|
+
console.log(`Video has been Played at time (${time} sec)`);
|
111
|
+
};
|
112
|
+
|
113
|
+
return (
|
114
|
+
<SoftBuildersVideoPlayer
|
115
|
+
options={options}
|
116
|
+
chapters={initChapters}
|
117
|
+
notes={initNotes}
|
118
|
+
handleSaveNoteAction={handleSaveNoteAction}
|
119
|
+
onPause={onPause}
|
120
|
+
onPlay={onPlay}
|
121
|
+
/>
|
122
|
+
);
|
123
|
+
};
|
124
|
+
|
125
|
+
export default Component;
|
126
|
+
```
|
@@ -1,19 +1,19 @@
|
|
1
|
-
import React, { useEffect } from "react";
|
2
|
-
import { useSoftBuildersVideoPlayerContext } from "../VideoPlayerComponent/provider";
|
3
|
-
|
4
|
-
const BufferTracker = () => {
|
5
|
-
const { player, setDownloadedBufferTimeufferTime } =
|
6
|
-
useSoftBuildersVideoPlayerContext();
|
7
|
-
|
8
|
-
useEffect(() => {
|
9
|
-
const intervalId = setInterval(() => {
|
10
|
-
if (player) setDownloadedBufferTimeufferTime(player.bufferedEnd());
|
11
|
-
}, 1000);
|
12
|
-
|
13
|
-
// Cleanup function to clear the interval
|
14
|
-
return () => clearInterval(intervalId);
|
15
|
-
}, [player]);
|
16
|
-
return <></>;
|
17
|
-
};
|
18
|
-
|
19
|
-
export default BufferTracker;
|
1
|
+
import React, { useEffect } from "react";
|
2
|
+
import { useSoftBuildersVideoPlayerContext } from "../VideoPlayerComponent/provider";
|
3
|
+
|
4
|
+
const BufferTracker = () => {
|
5
|
+
const { player, setDownloadedBufferTimeufferTime } =
|
6
|
+
useSoftBuildersVideoPlayerContext();
|
7
|
+
|
8
|
+
useEffect(() => {
|
9
|
+
const intervalId = setInterval(() => {
|
10
|
+
if (player) setDownloadedBufferTimeufferTime(player.bufferedEnd());
|
11
|
+
}, 1000);
|
12
|
+
|
13
|
+
// Cleanup function to clear the interval
|
14
|
+
return () => clearInterval(intervalId);
|
15
|
+
}, [player]);
|
16
|
+
return <></>;
|
17
|
+
};
|
18
|
+
|
19
|
+
export default BufferTracker;
|
@@ -1,65 +1,65 @@
|
|
1
|
-
import React, { useEffect, useState } from "react";
|
2
|
-
import Tooltip from "../Tooltip";
|
3
|
-
import { durationFormater } from "../../utils";
|
4
|
-
import { SoftBuildersVideoPlayerChapter } from "../../types";
|
5
|
-
import { useSoftBuildersVideoPlayerContext } from "../VideoPlayerComponent/provider";
|
6
|
-
type Chapter = SoftBuildersVideoPlayerChapter & {
|
7
|
-
startPercentage: number;
|
8
|
-
endPercentage: number;
|
9
|
-
};
|
10
|
-
type Props = {
|
11
|
-
chapter: Chapter;
|
12
|
-
};
|
13
|
-
const ChapterTooltip = ({ chapter }: Props) => {
|
14
|
-
const { player } = useSoftBuildersVideoPlayerContext();
|
15
|
-
|
16
|
-
const [open, setOpen] = useState(false);
|
17
|
-
const { currentTime } = useSoftBuildersVideoPlayerContext();
|
18
|
-
|
19
|
-
useEffect(() => {
|
20
|
-
if (currentTime === Math.floor(chapter.startTime)) {
|
21
|
-
setOpen(true);
|
22
|
-
|
23
|
-
setTimeout(() => {
|
24
|
-
setOpen(false);
|
25
|
-
}, 5000);
|
26
|
-
}
|
27
|
-
}, [currentTime, chapter.startTime]);
|
28
|
-
|
29
|
-
const handleClickChapter = () => {
|
30
|
-
player?.currentTime(chapter.startTime);
|
31
|
-
};
|
32
|
-
|
33
|
-
return (
|
34
|
-
<div
|
35
|
-
id={`ii-section-${chapter.title}`}
|
36
|
-
className="sb-flex sb-items-center sb-w-full sb-h-full sb-absolute sb-z-20"
|
37
|
-
style={{
|
38
|
-
left: `${chapter.startPercentage}%`,
|
39
|
-
width: `${chapter.endPercentage - chapter.startPercentage}%`,
|
40
|
-
}}
|
41
|
-
onMouseEnter={() => setOpen(true)}
|
42
|
-
onMouseLeave={() => setOpen(false)}
|
43
|
-
>
|
44
|
-
<button
|
45
|
-
id={`section-${chapter.title}`}
|
46
|
-
className="sb-h-full sb-w-full"
|
47
|
-
onClick={handleClickChapter}
|
48
|
-
>
|
49
|
-
<div className="sb-relative sb-flex sb-h-full sb-w-full sb-justify-between sb-items-center">
|
50
|
-
<Tooltip open={open}>
|
51
|
-
<div className="sb-flex sb-flex-col sb-gap-2 sb-items-center">
|
52
|
-
<p>{chapter.title}</p>
|
53
|
-
<p className="sb-p-2 sb-bg-[#303030] sb-bg-opacity-50 sb-rounded-md">
|
54
|
-
{durationFormater(chapter.startTime)} -{" "}
|
55
|
-
{durationFormater(chapter.endTime)}
|
56
|
-
</p>
|
57
|
-
</div>
|
58
|
-
</Tooltip>
|
59
|
-
</div>
|
60
|
-
</button>
|
61
|
-
</div>
|
62
|
-
);
|
63
|
-
};
|
64
|
-
|
65
|
-
export default ChapterTooltip;
|
1
|
+
import React, { useEffect, useState } from "react";
|
2
|
+
import Tooltip from "../Tooltip";
|
3
|
+
import { durationFormater } from "../../utils";
|
4
|
+
import { SoftBuildersVideoPlayerChapter } from "../../types";
|
5
|
+
import { useSoftBuildersVideoPlayerContext } from "../VideoPlayerComponent/provider";
|
6
|
+
type Chapter = SoftBuildersVideoPlayerChapter & {
|
7
|
+
startPercentage: number;
|
8
|
+
endPercentage: number;
|
9
|
+
};
|
10
|
+
type Props = {
|
11
|
+
chapter: Chapter;
|
12
|
+
};
|
13
|
+
const ChapterTooltip = ({ chapter }: Props) => {
|
14
|
+
const { player } = useSoftBuildersVideoPlayerContext();
|
15
|
+
|
16
|
+
const [open, setOpen] = useState(false);
|
17
|
+
const { currentTime } = useSoftBuildersVideoPlayerContext();
|
18
|
+
|
19
|
+
useEffect(() => {
|
20
|
+
if (currentTime === Math.floor(chapter.startTime)) {
|
21
|
+
setOpen(true);
|
22
|
+
|
23
|
+
setTimeout(() => {
|
24
|
+
setOpen(false);
|
25
|
+
}, 5000);
|
26
|
+
}
|
27
|
+
}, [currentTime, chapter.startTime]);
|
28
|
+
|
29
|
+
const handleClickChapter = () => {
|
30
|
+
player?.currentTime(chapter.startTime);
|
31
|
+
};
|
32
|
+
|
33
|
+
return (
|
34
|
+
<div
|
35
|
+
id={`ii-section-${chapter.title}`}
|
36
|
+
className="sb-flex sb-items-center sb-w-full sb-h-full sb-absolute sb-z-20"
|
37
|
+
style={{
|
38
|
+
left: `${chapter.startPercentage}%`,
|
39
|
+
width: `${chapter.endPercentage - chapter.startPercentage}%`,
|
40
|
+
}}
|
41
|
+
onMouseEnter={() => setOpen(true)}
|
42
|
+
onMouseLeave={() => setOpen(false)}
|
43
|
+
>
|
44
|
+
<button
|
45
|
+
id={`section-${chapter.title}`}
|
46
|
+
className="sb-h-full sb-w-full"
|
47
|
+
onClick={handleClickChapter}
|
48
|
+
>
|
49
|
+
<div className="sb-relative sb-flex sb-h-full sb-w-full sb-justify-between sb-items-center">
|
50
|
+
<Tooltip open={open}>
|
51
|
+
<div className="sb-flex sb-flex-col sb-gap-2 sb-items-center">
|
52
|
+
<p>{chapter.title}</p>
|
53
|
+
<p className="sb-p-2 sb-bg-[#303030] sb-bg-opacity-50 sb-rounded-md">
|
54
|
+
{durationFormater(chapter.startTime)} -{" "}
|
55
|
+
{durationFormater(chapter.endTime)}
|
56
|
+
</p>
|
57
|
+
</div>
|
58
|
+
</Tooltip>
|
59
|
+
</div>
|
60
|
+
</button>
|
61
|
+
</div>
|
62
|
+
);
|
63
|
+
};
|
64
|
+
|
65
|
+
export default ChapterTooltip;
|
@@ -1,40 +1,40 @@
|
|
1
|
-
import React, { useEffect, useState } from "react";
|
2
|
-
|
3
|
-
import ChapterTooltip from "../ChapterTooltip";
|
4
|
-
import { SoftBuildersVideoPlayerChapter } from "../../types";
|
5
|
-
import { useSoftBuildersVideoPlayerContext } from "../VideoPlayerComponent/provider";
|
6
|
-
|
7
|
-
type Chapter = SoftBuildersVideoPlayerChapter & {
|
8
|
-
startPercentage: number;
|
9
|
-
endPercentage: number;
|
10
|
-
};
|
11
|
-
type Props = {
|
12
|
-
chapters: SoftBuildersVideoPlayerChapter[];
|
13
|
-
};
|
14
|
-
const ChaptersPanal = ({ chapters }: Props) => {
|
15
|
-
const [cs, setCs] = useState<Chapter[]>([]);
|
16
|
-
const { duration } = useSoftBuildersVideoPlayerContext();
|
17
|
-
|
18
|
-
useEffect(() => {
|
19
|
-
const newCs = chapters.map((c) => {
|
20
|
-
const startPercentage = Math.floor((c.startTime * 100) / duration);
|
21
|
-
const endPercentage = Math.floor((c.endTime * 100) / duration);
|
22
|
-
return {
|
23
|
-
...c,
|
24
|
-
startPercentage,
|
25
|
-
endPercentage,
|
26
|
-
};
|
27
|
-
});
|
28
|
-
setCs(newCs);
|
29
|
-
}, [chapters, duration]);
|
30
|
-
|
31
|
-
return (
|
32
|
-
<div id="chapters-panal" className="sb-w-full sb-h-full sb-relative ">
|
33
|
-
{cs.map((c, i) => (
|
34
|
-
<ChapterTooltip key={`chapter-${i}-${c.startTime}`} chapter={c} />
|
35
|
-
))}
|
36
|
-
</div>
|
37
|
-
);
|
38
|
-
};
|
39
|
-
|
40
|
-
export default ChaptersPanal;
|
1
|
+
import React, { useEffect, useState } from "react";
|
2
|
+
|
3
|
+
import ChapterTooltip from "../ChapterTooltip";
|
4
|
+
import { SoftBuildersVideoPlayerChapter } from "../../types";
|
5
|
+
import { useSoftBuildersVideoPlayerContext } from "../VideoPlayerComponent/provider";
|
6
|
+
|
7
|
+
type Chapter = SoftBuildersVideoPlayerChapter & {
|
8
|
+
startPercentage: number;
|
9
|
+
endPercentage: number;
|
10
|
+
};
|
11
|
+
type Props = {
|
12
|
+
chapters: SoftBuildersVideoPlayerChapter[];
|
13
|
+
};
|
14
|
+
const ChaptersPanal = ({ chapters }: Props) => {
|
15
|
+
const [cs, setCs] = useState<Chapter[]>([]);
|
16
|
+
const { duration } = useSoftBuildersVideoPlayerContext();
|
17
|
+
|
18
|
+
useEffect(() => {
|
19
|
+
const newCs = chapters.map((c) => {
|
20
|
+
const startPercentage = Math.floor((c.startTime * 100) / duration);
|
21
|
+
const endPercentage = Math.floor((c.endTime * 100) / duration);
|
22
|
+
return {
|
23
|
+
...c,
|
24
|
+
startPercentage,
|
25
|
+
endPercentage,
|
26
|
+
};
|
27
|
+
});
|
28
|
+
setCs(newCs);
|
29
|
+
}, [chapters, duration]);
|
30
|
+
|
31
|
+
return (
|
32
|
+
<div id="chapters-panal" className="sb-w-full sb-h-full sb-relative ">
|
33
|
+
{cs.map((c, i) => (
|
34
|
+
<ChapterTooltip key={`chapter-${i}-${c.startTime}`} chapter={c} />
|
35
|
+
))}
|
36
|
+
</div>
|
37
|
+
);
|
38
|
+
};
|
39
|
+
|
40
|
+
export default ChaptersPanal;
|
@@ -23,7 +23,7 @@ const ControlBar = ({ player, isPaused, setIsPaused, duration, notes, chapters,
|
|
23
23
|
setwidth(width);
|
24
24
|
}
|
25
25
|
const resizeObserver = new ResizeObserver((entries) => {
|
26
|
-
for (
|
26
|
+
for (const entry of entries) {
|
27
27
|
const currentWidth = entry.contentRect.width;
|
28
28
|
handleWidthChange(currentWidth); // Call the action when width changes
|
29
29
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/ControlBar/index.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAGnD,OAAO,gBAAgB,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,YAAY,MAAM,iBAAiB,CAAC;AAC3C,OAAO,WAAW,MAAM,gBAAgB,CAA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YAAY,KAAG,IACZ,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
@@ -58,7 +58,7 @@ const ControlBar = <T,>({
|
|
58
58
|
setwidth(width);
|
59
59
|
}
|
60
60
|
const resizeObserver = new ResizeObserver((entries) => {
|
61
|
-
for (
|
61
|
+
for (const entry of entries) {
|
62
62
|
const currentWidth = entry.contentRect.width;
|
63
63
|
handleWidthChange(currentWidth); // Call the action when width changes
|
64
64
|
}
|
@@ -66,7 +66,7 @@ const ControlBar = <T,>({
|
|
66
66
|
|
67
67
|
// Start observing the element
|
68
68
|
container && resizeObserver.observe(container);
|
69
|
-
const togglePlay = (e
|
69
|
+
const togglePlay = (e) => {
|
70
70
|
e.preventDefault();
|
71
71
|
e.stopPropagation();
|
72
72
|
|