softbuilders-react-video-player 1.1.14 → 1.1.16
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/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 -2
- package/dist/components/ControlBar/index.js.map +1 -1
- package/dist/components/ControlBar/index.tsx +3 -4
- 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 +1 -1
- package/dist/components/VideoPlayerComponent/index.js.map +1 -1
- package/dist/components/VideoPlayerComponent/index.tsx +2 -33
- package/dist/components/VideoPlayerComponent/provider.tsx +82 -82
- package/dist/components/VideoPlayerComponent/style/style.css +36 -36
- package/dist/components/VolumeSlider/index.js +1 -1
- package/dist/components/VolumeSlider/index.js.map +1 -1
- package/dist/components/VolumeSlider/index.tsx +2 -12
- package/dist/index.mjs +3 -4
- package/dist/styles/tailwind.css +101 -101
- package/package.json +1 -1
@@ -1,82 +1,82 @@
|
|
1
|
-
import React, {
|
2
|
-
createContext,
|
3
|
-
useContext,
|
4
|
-
useState,
|
5
|
-
ReactNode,
|
6
|
-
useEffect,
|
7
|
-
} from "react";
|
8
|
-
import Player from "video.js/dist/types/player";
|
9
|
-
|
10
|
-
interface SoftBuildersVideoPlayerContextType {
|
11
|
-
player: Player | undefined;
|
12
|
-
setPlayer: React.Dispatch<React.SetStateAction<Player | undefined>>;
|
13
|
-
|
14
|
-
currentTime: number;
|
15
|
-
setCurrentTime: (value: number) => void;
|
16
|
-
|
17
|
-
duration: number;
|
18
|
-
setDuration: React.Dispatch<React.SetStateAction<number>>;
|
19
|
-
|
20
|
-
// isPaused: boolean;
|
21
|
-
// setIsPaused: React.Dispatch<React.SetStateAction<boolean>>;
|
22
|
-
|
23
|
-
downloadedBufferPercentage: number;
|
24
|
-
downloadedBufferTime: number;
|
25
|
-
setDownloadedBufferTimeufferTime: React.Dispatch<
|
26
|
-
React.SetStateAction<number>
|
27
|
-
>;
|
28
|
-
}
|
29
|
-
|
30
|
-
const SoftBuildersVideoPlayerContext = createContext<
|
31
|
-
SoftBuildersVideoPlayerContextType | undefined
|
32
|
-
>(undefined);
|
33
|
-
|
34
|
-
// Create a provider component
|
35
|
-
export const SoftBuildersVideoPlayerProvider = ({
|
36
|
-
children,
|
37
|
-
}: {
|
38
|
-
children: ReactNode;
|
39
|
-
}) => {
|
40
|
-
const [player, setPlayer] = useState<Player | undefined>(undefined);
|
41
|
-
const [currentTime, setCurrentTime] = useState<number>(0);
|
42
|
-
const [duration, setDuration] = useState<number>(1);
|
43
|
-
// const [isPaused, setIsPaused] = useState(false);
|
44
|
-
const [downloadedBufferTime, setDownloadedBufferTimeufferTime] = useState(0);
|
45
|
-
const [downloadedBufferPercentage, setDownloadedBufferPercentage] =
|
46
|
-
useState(0);
|
47
|
-
|
48
|
-
useEffect(() => {
|
49
|
-
setDownloadedBufferPercentage((downloadedBufferTime * 100) / duration);
|
50
|
-
}, [downloadedBufferTime]);
|
51
|
-
|
52
|
-
return (
|
53
|
-
<SoftBuildersVideoPlayerContext.Provider
|
54
|
-
value={{
|
55
|
-
player,
|
56
|
-
setPlayer,
|
57
|
-
duration,
|
58
|
-
setDuration,
|
59
|
-
currentTime,
|
60
|
-
setCurrentTime: (value) => setCurrentTime(Math.floor(value)),
|
61
|
-
// isPaused,
|
62
|
-
// setIsPaused,
|
63
|
-
downloadedBufferTime,
|
64
|
-
setDownloadedBufferTimeufferTime,
|
65
|
-
downloadedBufferPercentage,
|
66
|
-
}}
|
67
|
-
>
|
68
|
-
{children}
|
69
|
-
</SoftBuildersVideoPlayerContext.Provider>
|
70
|
-
);
|
71
|
-
};
|
72
|
-
|
73
|
-
// Custom hook to use the context
|
74
|
-
export const useSoftBuildersVideoPlayerContext = () => {
|
75
|
-
const context = useContext(SoftBuildersVideoPlayerContext);
|
76
|
-
if (!context) {
|
77
|
-
throw new Error(
|
78
|
-
"useSoftBuildersVideoPlayerContext must be used within an SoftBuildersVideoPlayerProvider"
|
79
|
-
);
|
80
|
-
}
|
81
|
-
return context;
|
82
|
-
};
|
1
|
+
import React, {
|
2
|
+
createContext,
|
3
|
+
useContext,
|
4
|
+
useState,
|
5
|
+
ReactNode,
|
6
|
+
useEffect,
|
7
|
+
} from "react";
|
8
|
+
import Player from "video.js/dist/types/player";
|
9
|
+
|
10
|
+
interface SoftBuildersVideoPlayerContextType {
|
11
|
+
player: Player | undefined;
|
12
|
+
setPlayer: React.Dispatch<React.SetStateAction<Player | undefined>>;
|
13
|
+
|
14
|
+
currentTime: number;
|
15
|
+
setCurrentTime: (value: number) => void;
|
16
|
+
|
17
|
+
duration: number;
|
18
|
+
setDuration: React.Dispatch<React.SetStateAction<number>>;
|
19
|
+
|
20
|
+
// isPaused: boolean;
|
21
|
+
// setIsPaused: React.Dispatch<React.SetStateAction<boolean>>;
|
22
|
+
|
23
|
+
downloadedBufferPercentage: number;
|
24
|
+
downloadedBufferTime: number;
|
25
|
+
setDownloadedBufferTimeufferTime: React.Dispatch<
|
26
|
+
React.SetStateAction<number>
|
27
|
+
>;
|
28
|
+
}
|
29
|
+
|
30
|
+
const SoftBuildersVideoPlayerContext = createContext<
|
31
|
+
SoftBuildersVideoPlayerContextType | undefined
|
32
|
+
>(undefined);
|
33
|
+
|
34
|
+
// Create a provider component
|
35
|
+
export const SoftBuildersVideoPlayerProvider = ({
|
36
|
+
children,
|
37
|
+
}: {
|
38
|
+
children: ReactNode;
|
39
|
+
}) => {
|
40
|
+
const [player, setPlayer] = useState<Player | undefined>(undefined);
|
41
|
+
const [currentTime, setCurrentTime] = useState<number>(0);
|
42
|
+
const [duration, setDuration] = useState<number>(1);
|
43
|
+
// const [isPaused, setIsPaused] = useState(false);
|
44
|
+
const [downloadedBufferTime, setDownloadedBufferTimeufferTime] = useState(0);
|
45
|
+
const [downloadedBufferPercentage, setDownloadedBufferPercentage] =
|
46
|
+
useState(0);
|
47
|
+
|
48
|
+
useEffect(() => {
|
49
|
+
setDownloadedBufferPercentage((downloadedBufferTime * 100) / duration);
|
50
|
+
}, [downloadedBufferTime]);
|
51
|
+
|
52
|
+
return (
|
53
|
+
<SoftBuildersVideoPlayerContext.Provider
|
54
|
+
value={{
|
55
|
+
player,
|
56
|
+
setPlayer,
|
57
|
+
duration,
|
58
|
+
setDuration,
|
59
|
+
currentTime,
|
60
|
+
setCurrentTime: (value) => setCurrentTime(Math.floor(value)),
|
61
|
+
// isPaused,
|
62
|
+
// setIsPaused,
|
63
|
+
downloadedBufferTime,
|
64
|
+
setDownloadedBufferTimeufferTime,
|
65
|
+
downloadedBufferPercentage,
|
66
|
+
}}
|
67
|
+
>
|
68
|
+
{children}
|
69
|
+
</SoftBuildersVideoPlayerContext.Provider>
|
70
|
+
);
|
71
|
+
};
|
72
|
+
|
73
|
+
// Custom hook to use the context
|
74
|
+
export const useSoftBuildersVideoPlayerContext = () => {
|
75
|
+
const context = useContext(SoftBuildersVideoPlayerContext);
|
76
|
+
if (!context) {
|
77
|
+
throw new Error(
|
78
|
+
"useSoftBuildersVideoPlayerContext must be used within an SoftBuildersVideoPlayerProvider"
|
79
|
+
);
|
80
|
+
}
|
81
|
+
return context;
|
82
|
+
};
|
@@ -1,36 +1,36 @@
|
|
1
|
-
.video-js .vjs-control-bar {
|
2
|
-
background-color: transparent;
|
3
|
-
display: none;
|
4
|
-
}
|
5
|
-
|
6
|
-
.video-js .vjs-big-play-button {
|
7
|
-
background-color: transparent;
|
8
|
-
display: block;
|
9
|
-
border: none;
|
10
|
-
padding: 0px;
|
11
|
-
opacity: 0;
|
12
|
-
transition: opacity 0.5s ease-in-out;
|
13
|
-
}
|
14
|
-
|
15
|
-
.video-js:hover .vjs-big-play-button {
|
16
|
-
background-color: transparent;
|
17
|
-
border: none;
|
18
|
-
padding: 0px;
|
19
|
-
opacity: 1;
|
20
|
-
transition: opacity 0.5s ease-in-out;
|
21
|
-
}
|
22
|
-
|
23
|
-
.vjs-poster {
|
24
|
-
display: inline-block;
|
25
|
-
vertical-align: middle;
|
26
|
-
cursor: pointer;
|
27
|
-
margin: 0;
|
28
|
-
padding: 0;
|
29
|
-
position: absolute;
|
30
|
-
top: 0;
|
31
|
-
right: 0;
|
32
|
-
bottom: 0;
|
33
|
-
left: 0;
|
34
|
-
height: 100%;
|
35
|
-
background-color: black;
|
36
|
-
}
|
1
|
+
.video-js .vjs-control-bar {
|
2
|
+
background-color: transparent;
|
3
|
+
display: none;
|
4
|
+
}
|
5
|
+
|
6
|
+
.video-js .vjs-big-play-button {
|
7
|
+
background-color: transparent;
|
8
|
+
display: block;
|
9
|
+
border: none;
|
10
|
+
padding: 0px;
|
11
|
+
opacity: 0;
|
12
|
+
transition: opacity 0.5s ease-in-out;
|
13
|
+
}
|
14
|
+
|
15
|
+
.video-js:hover .vjs-big-play-button {
|
16
|
+
background-color: transparent;
|
17
|
+
border: none;
|
18
|
+
padding: 0px;
|
19
|
+
opacity: 1;
|
20
|
+
transition: opacity 0.5s ease-in-out;
|
21
|
+
}
|
22
|
+
|
23
|
+
.vjs-poster {
|
24
|
+
display: inline-block;
|
25
|
+
vertical-align: middle;
|
26
|
+
cursor: pointer;
|
27
|
+
margin: 0;
|
28
|
+
padding: 0;
|
29
|
+
position: absolute;
|
30
|
+
top: 0;
|
31
|
+
right: 0;
|
32
|
+
bottom: 0;
|
33
|
+
left: 0;
|
34
|
+
height: 100%;
|
35
|
+
background-color: black;
|
36
|
+
}
|
@@ -4,7 +4,7 @@ import Slider from "../Slider";
|
|
4
4
|
import { useSoftBuildersVideoPlayerContext } from "../VideoPlayerComponent/provider";
|
5
5
|
import { MuteIcon, UnmuteIcon } from "../../images";
|
6
6
|
const MIN = 0, MAX = 100;
|
7
|
-
const VolumeSlider = ({ width }) => {
|
7
|
+
const VolumeSlider = ({ width = 0 }) => {
|
8
8
|
const { player } = useSoftBuildersVideoPlayerContext();
|
9
9
|
const [isVisible, setVisible] = useState(false);
|
10
10
|
const [volume, setVolume] = useState(0);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/VolumeSlider/index.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACnD,OAAO,MAAM,MAAM,WAAW,CAAC;AAC/B,OAAO,EAAE,iCAAiC,EAAE,MAAM,kCAAkC,CAAC;AACrF,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/VolumeSlider/index.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACnD,OAAO,MAAM,MAAM,WAAW,CAAC;AAC/B,OAAO,EAAE,iCAAiC,EAAE,MAAM,kCAAkC,CAAC;AACrF,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACpD,MAAM,GAAG,GAAG,CAAC,EACX,GAAG,GAAG,GAAG,CAAC;AAIZ,MAAM,YAAY,GAAG,CAAC,EAAE,KAAK,GAAG,CAAC,EAAS,EAAE,EAAE;IAC5C,MAAM,EAAE,MAAM,EAAE,GAAG,iCAAiC,EAAE,CAAC;IACvD,MAAM,CAAC,SAAS,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;I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AAC,CAAC,CAAC,EAC/C,sDAAsD,aAGtD,cACE,SAAS,EAAE,uBACT,KAAK,GAAG,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EACrB,wBAAwB,EACxB,OAAO,EAAE,eAAe,YAEvB,MAAM,KAAK,CAAC,KAAI,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,EAAE,CAAA,CAAC,CAAC,CAAC,CACjC,KAAC,QAAQ,IACP,SAAS,EAAE,iBAAiB,KAAK,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,iBAAiB,GACnE,CACH,CAAC,CAAC,CAAC,CACF,KAAC,UAAU,IACT,SAAS,EAAE,iBAAiB,KAAK,GAAG,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,gBAAgB,GACjE,CACH,GACG,EAEN,cAAK,SAAS,EAAC,2CAA2C,YAExD,cACE,SAAS,EAAE,GACT,SAAS,IAAI,KAAK,GAAG,GAAG;wBACtB,CAAC,CAAC,cAAc;wBAChB,CAAC,CAAC,CAAC,SAAS,IAAI,KAAK,GAAG,GAAG;4BAC3B,CAAC,CAAC,WAAW;4BACb,CAAC,CAAC,EACN,kDACE,KAAK,GAAG,GAAG;wBACT,CAAC,CAAC,iDAAiD;wBACnD,CAAC,CAAC,kBACN,EAAE,YAEF,KAAC,MAAM,IACL,KAAK,EAAE,MAAM,EACb,iBAAiB,EAAE,iBAAiB,EACpC,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,GAAG,EACR,SAAS,EAAC,UAAU,GACpB,GACE,GACF,IACF,CACP,CAAC;AACJ,CAAC,CAAC;AACF,eAAe,YAAY,CAAC"}
|
@@ -2,44 +2,35 @@ import React, { useEffect, useState } from "react";
|
|
2
2
|
import Slider from "../Slider";
|
3
3
|
import { useSoftBuildersVideoPlayerContext } from "../VideoPlayerComponent/provider";
|
4
4
|
import { MuteIcon, UnmuteIcon } from "../../images";
|
5
|
-
|
6
5
|
const MIN = 0,
|
7
6
|
MAX = 100;
|
8
|
-
|
9
7
|
type Props = {
|
10
8
|
width?: number;
|
11
9
|
};
|
12
|
-
|
13
|
-
const VolumeSlider = ({ width }: Props) => {
|
10
|
+
const VolumeSlider = ({ width = 0 }: Props) => {
|
14
11
|
const { player } = useSoftBuildersVideoPlayerContext();
|
15
12
|
const [isVisible, setVisible] = useState(false);
|
16
13
|
const [volume, setVolume] = useState(0);
|
17
|
-
|
18
14
|
useEffect(() => {
|
19
15
|
setVolume(player?.muted() ? 0 : Number(player?.volume()) * 100 || 0);
|
20
16
|
}, [player]);
|
21
|
-
const toggleVisiblity = (e) => {
|
17
|
+
const toggleVisiblity = (e: any) => {
|
22
18
|
e.preventDefault();
|
23
19
|
e.stopPropagation();
|
24
20
|
setVisible((prev) => !prev);
|
25
21
|
};
|
26
|
-
|
27
22
|
const handleValueChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
28
23
|
e.preventDefault();
|
29
24
|
e.stopPropagation();
|
30
25
|
const newVolume = Number(e.target.value);
|
31
|
-
|
32
26
|
setVolume(newVolume);
|
33
|
-
|
34
27
|
player?.volume(newVolume / 100);
|
35
|
-
|
36
28
|
if (newVolume === 0) {
|
37
29
|
player?.muted(true);
|
38
30
|
} else {
|
39
31
|
player?.muted(false);
|
40
32
|
}
|
41
33
|
};
|
42
|
-
|
43
34
|
return (
|
44
35
|
<div
|
45
36
|
className={`sb-flex sb-flex-col-reverse ${
|
@@ -91,5 +82,4 @@ const VolumeSlider = ({ width }: Props) => {
|
|
91
82
|
</div>
|
92
83
|
);
|
93
84
|
};
|
94
|
-
|
95
85
|
export default VolumeSlider;
|
package/dist/index.mjs
CHANGED
@@ -510,7 +510,7 @@ var SubIcon_default = SvgSubIcon;
|
|
510
510
|
import { jsx as jsx19, jsxs as jsxs4 } from "react/jsx-runtime";
|
511
511
|
var MIN = 0;
|
512
512
|
var MAX = 100;
|
513
|
-
var VolumeSlider = ({ width }) => {
|
513
|
+
var VolumeSlider = ({ width = 0 }) => {
|
514
514
|
const { player } = useSoftBuildersVideoPlayerContext();
|
515
515
|
const [isVisible, setVisible] = useState2(false);
|
516
516
|
const [volume, setVolume] = useState2(0);
|
@@ -1129,7 +1129,7 @@ var ControlBar = ({
|
|
1129
1129
|
handleSaveNoteAction
|
1130
1130
|
}) => {
|
1131
1131
|
const { setPlayer, setDuration } = useSoftBuildersVideoPlayerContext();
|
1132
|
-
const [width, setwidth] = useState12(
|
1132
|
+
const [width, setwidth] = useState12(0);
|
1133
1133
|
const seek = (duration2) => {
|
1134
1134
|
const currentTime = Number((player == null ? void 0 : player.currentTime()) || 0);
|
1135
1135
|
player == null ? void 0 : player.currentTime(currentTime + duration2);
|
@@ -1148,7 +1148,6 @@ var ControlBar = ({
|
|
1148
1148
|
const togglePlay = (e) => {
|
1149
1149
|
e.preventDefault();
|
1150
1150
|
e.stopPropagation();
|
1151
|
-
console.log("ok");
|
1152
1151
|
if (isPaused) player == null ? void 0 : player.play();
|
1153
1152
|
else player == null ? void 0 : player.pause();
|
1154
1153
|
setIsPaused(!isPaused);
|
@@ -1408,7 +1407,7 @@ var VideoPlayerComponent = ({
|
|
1408
1407
|
} else {
|
1409
1408
|
playerRef.current.pause();
|
1410
1409
|
setIsPaused(true);
|
1411
|
-
if (onPause) onPause(playerRef.current.currentTime());
|
1410
|
+
if (onPause) onPause(playerRef.current.currentTime() || 0);
|
1412
1411
|
}
|
1413
1412
|
}
|
1414
1413
|
};
|