softbuilders-react-video-player 1.3.1 → 1.3.3
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/components/QualityMenu/index.js +11 -5
- package/dist/components/QualityMenu/index.js.map +1 -1
- package/dist/components/QualityMenu/index.tsx +11 -5
- package/dist/components/SoftBuildersVideoPlayer/index.d.ts +1 -1
- package/dist/components/SoftBuildersVideoPlayer/index.js +5 -4
- package/dist/components/SoftBuildersVideoPlayer/index.js.map +1 -1
- package/dist/components/SoftBuildersVideoPlayer/index.tsx +90 -87
- package/dist/components/VideoPlayerComponent/index.d.ts +1 -1
- package/dist/components/VideoPlayerComponent/index.js +3 -3
- package/dist/components/VideoPlayerComponent/index.js.map +1 -1
- package/dist/components/VideoPlayerComponent/index.tsx +407 -411
- package/dist/index.d.mts +2 -1
- package/dist/index.mjs +442 -440
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
@@ -31,11 +31,10 @@ var __objRest = (source, exclude) => {
|
|
31
31
|
};
|
32
32
|
|
33
33
|
// src/components/SoftBuildersVideoPlayer/index.tsx
|
34
|
-
import {
|
34
|
+
import { memo, useEffect as useEffect16, useState as useState15 } from "react";
|
35
35
|
|
36
36
|
// src/components/VideoPlayerComponent/index.tsx
|
37
37
|
import {
|
38
|
-
forwardRef,
|
39
38
|
Suspense,
|
40
39
|
useEffect as useEffect15,
|
41
40
|
useRef as useRef2,
|
@@ -910,10 +909,15 @@ var QualityMenu = ({
|
|
910
909
|
const qs = JSON.parse(
|
911
910
|
JSON.stringify(sources)
|
912
911
|
);
|
913
|
-
|
914
|
-
|
915
|
-
|
916
|
-
|
912
|
+
player.on("loadedmetadata", () => {
|
913
|
+
const qualityLevels = player == null ? void 0 : player.qualityLevels();
|
914
|
+
if ((qualityLevels == null ? void 0 : qualityLevels.length) > 0) {
|
915
|
+
setQualities((prev) => [
|
916
|
+
...qualityLevels,
|
917
|
+
{ height: "auto", width: "auto" }
|
918
|
+
]);
|
919
|
+
}
|
920
|
+
});
|
917
921
|
const source = player == null ? void 0 : player.currentSource();
|
918
922
|
const quality = JSON.parse(
|
919
923
|
JSON.stringify(source)
|
@@ -995,6 +999,7 @@ var QualityMenu = ({
|
|
995
999
|
isSelected: currentQualitySrc === (q == null ? void 0 : q.height),
|
996
1000
|
quality: q,
|
997
1001
|
onClick: (e) => {
|
1002
|
+
setCurrentQualitySrc(q == null ? void 0 : q.height);
|
998
1003
|
q.height != "auto" ? setQualityByHeight(q.height) : setAutoQuality();
|
999
1004
|
closeMenuFunction && closeMenuFunction();
|
1000
1005
|
setIsModalChanged(false);
|
@@ -1873,76 +1878,118 @@ var renderControlBar = (id, player, isPaused, setIsPaused, duration, notes, chap
|
|
1873
1878
|
}
|
1874
1879
|
}
|
1875
1880
|
};
|
1876
|
-
var VideoPlayerComponent =
|
1877
|
-
|
1878
|
-
|
1879
|
-
|
1880
|
-
|
1881
|
-
|
1882
|
-
|
1883
|
-
|
1884
|
-
|
1885
|
-
|
1886
|
-
|
1887
|
-
|
1888
|
-
|
1889
|
-
|
1890
|
-
|
1891
|
-
|
1892
|
-
|
1893
|
-
|
1894
|
-
|
1895
|
-
|
1896
|
-
|
1897
|
-
|
1898
|
-
|
1899
|
-
|
1900
|
-
|
1901
|
-
|
1902
|
-
|
1903
|
-
|
1904
|
-
|
1905
|
-
|
1906
|
-
|
1907
|
-
|
1908
|
-
|
1909
|
-
|
1910
|
-
|
1911
|
-
|
1912
|
-
|
1913
|
-
|
1914
|
-
|
1915
|
-
|
1916
|
-
|
1917
|
-
|
1918
|
-
|
1919
|
-
|
1920
|
-
|
1921
|
-
|
1922
|
-
player.
|
1923
|
-
|
1924
|
-
|
1925
|
-
|
1881
|
+
var VideoPlayerComponent = ({
|
1882
|
+
id,
|
1883
|
+
options,
|
1884
|
+
notes,
|
1885
|
+
chapters,
|
1886
|
+
startTime = 0,
|
1887
|
+
handleSaveNoteAction,
|
1888
|
+
poster,
|
1889
|
+
onPlay,
|
1890
|
+
onPause,
|
1891
|
+
disableNote,
|
1892
|
+
childRef,
|
1893
|
+
bottomRedBar = true,
|
1894
|
+
noteButtonClick,
|
1895
|
+
videoID,
|
1896
|
+
isTrailer,
|
1897
|
+
height
|
1898
|
+
}) => {
|
1899
|
+
var _a;
|
1900
|
+
const videoRef = useRef2(void 0);
|
1901
|
+
const playerRef = useRef2(void 0);
|
1902
|
+
const idRef = useRef2(void 0);
|
1903
|
+
const [isReady, setIsReady] = useState14(false);
|
1904
|
+
const [isPaused, setIsPaused] = useState14(!options.autoplay);
|
1905
|
+
const [duration, setDuration] = useState14(1);
|
1906
|
+
const [opacity, setOpacity] = useState14("0");
|
1907
|
+
const [isControlBarPresent, setIsControlBarPresent] = useState14(true);
|
1908
|
+
const [bgColor, setBgColor] = useState14("transparent");
|
1909
|
+
const [isQualityMenuOpen, setIsQualityMenuOpen] = useState14(false);
|
1910
|
+
const [isSubtitleMenuOpen, setIsSubtitleMenuOpen] = useState14(false);
|
1911
|
+
const [isHovered, setIsHovered] = useState14(false);
|
1912
|
+
const [isNoteOpen, setNoteOpen] = useState14(false);
|
1913
|
+
const [heightValue, setHeightValue] = useState14(0);
|
1914
|
+
const [isLoading, setIsloading] = useState14(false);
|
1915
|
+
const onReady = (player) => {
|
1916
|
+
if (playerRef) {
|
1917
|
+
playerRef.current = player;
|
1918
|
+
setIsReady(true);
|
1919
|
+
player == null ? void 0 : player.currentTime(startTime);
|
1920
|
+
player.on("waiting", () => {
|
1921
|
+
});
|
1922
|
+
player.on("dispose", () => {
|
1923
|
+
videojs.log("player will dispose");
|
1924
|
+
setIsReady(false);
|
1925
|
+
});
|
1926
|
+
player.on("loadedmetadata", () => {
|
1927
|
+
const d = player.duration() || 0;
|
1928
|
+
setDuration(d);
|
1929
|
+
});
|
1930
|
+
}
|
1931
|
+
};
|
1932
|
+
useEffect15(() => {
|
1933
|
+
if (!playerRef.current) {
|
1934
|
+
const videoElement = document.createElement("video-js");
|
1935
|
+
videoElement.setAttribute("playsinline", "true");
|
1936
|
+
videoElement.classList.add("vjs-big-play-centered");
|
1937
|
+
if (poster) {
|
1938
|
+
videoElement.setAttribute("poster", poster);
|
1939
|
+
}
|
1940
|
+
videoRef.current.appendChild(videoElement);
|
1941
|
+
videoElement.style.width = "100%";
|
1942
|
+
videoElement.style.height = "100%";
|
1943
|
+
videoElement.style.objectFit = "cover";
|
1944
|
+
playerRef.current = videojs(videoElement, options, () => {
|
1945
|
+
onReady(playerRef.current);
|
1946
|
+
});
|
1947
|
+
}
|
1948
|
+
return () => {
|
1949
|
+
if (playerRef.current) {
|
1950
|
+
idRef.current = options;
|
1951
|
+
playerRef.current.dispose();
|
1952
|
+
playerRef.current = void 0;
|
1953
|
+
setTimeout(() => {
|
1954
|
+
if (bigPlayButtonRoot[id]) {
|
1955
|
+
bigPlayButtonRoot[id].unmount();
|
1956
|
+
bigPlayButtonRoot[id] = void 0;
|
1957
|
+
}
|
1958
|
+
if (controlBarRoot[id]) {
|
1959
|
+
controlBarRoot[id].unmount();
|
1960
|
+
controlBarRoot[id] = void 0;
|
1961
|
+
}
|
1962
|
+
}, 0);
|
1926
1963
|
}
|
1927
1964
|
};
|
1928
|
-
|
1929
|
-
|
1930
|
-
|
1931
|
-
|
1932
|
-
|
1933
|
-
|
1934
|
-
|
1935
|
-
|
1936
|
-
|
1937
|
-
|
1938
|
-
|
1939
|
-
|
1940
|
-
|
1941
|
-
|
1942
|
-
|
1965
|
+
}, [id]);
|
1966
|
+
useEffect15(() => {
|
1967
|
+
if (playerRef.current) {
|
1968
|
+
const myPlayer = playerRef.current.currentSources();
|
1969
|
+
playerRef.current.src(options.sources);
|
1970
|
+
playerRef.current.load();
|
1971
|
+
}
|
1972
|
+
}, [options.sources[0].type]);
|
1973
|
+
useEffect15(() => {
|
1974
|
+
if (!playerRef.current) {
|
1975
|
+
const videoElement = document.createElement("video-js");
|
1976
|
+
videoElement.setAttribute("playsinline", "true");
|
1977
|
+
videoElement.classList.add("vjs-big-play-centered");
|
1978
|
+
if (poster) {
|
1979
|
+
videoElement.setAttribute("poster", poster);
|
1943
1980
|
}
|
1944
|
-
|
1945
|
-
|
1981
|
+
videoRef.current.appendChild(videoElement);
|
1982
|
+
videoElement.style.width = "100%";
|
1983
|
+
videoElement.style.height = "100%";
|
1984
|
+
videoElement.style.objectFit = "cover";
|
1985
|
+
playerRef.current = videojs(videoElement, options, () => {
|
1986
|
+
onReady(playerRef.current);
|
1987
|
+
});
|
1988
|
+
}
|
1989
|
+
return () => {
|
1990
|
+
var _a2, _b;
|
1991
|
+
if (playerRef.current) {
|
1992
|
+
if (!isEqual((_b = (_a2 = idRef == null ? void 0 : idRef.current) == null ? void 0 : _a2.sources) != null ? _b : "", options.sources)) {
|
1946
1993
|
idRef.current = options;
|
1947
1994
|
playerRef.current.dispose();
|
1948
1995
|
playerRef.current = void 0;
|
@@ -1957,323 +2004,279 @@ var VideoPlayerComponent = forwardRef(
|
|
1957
2004
|
}
|
1958
2005
|
}, 0);
|
1959
2006
|
}
|
1960
|
-
};
|
1961
|
-
}, [id]);
|
1962
|
-
useEffect15(() => {
|
1963
|
-
if (playerRef.current) {
|
1964
|
-
const myPlayer = playerRef.current.currentSources();
|
1965
|
-
playerRef.current.src(options.sources);
|
1966
|
-
playerRef.current.load();
|
1967
|
-
}
|
1968
|
-
}, [options.sources[0].type]);
|
1969
|
-
useEffect15(() => {
|
1970
|
-
if (!playerRef.current) {
|
1971
|
-
const videoElement = document.createElement("video-js");
|
1972
|
-
videoElement.setAttribute("playsinline", "true");
|
1973
|
-
videoElement.classList.add("vjs-big-play-centered");
|
1974
|
-
if (poster) {
|
1975
|
-
videoElement.setAttribute("poster", poster);
|
1976
|
-
}
|
1977
|
-
videoRef.current.appendChild(videoElement);
|
1978
|
-
videoElement.style.width = "100%";
|
1979
|
-
videoElement.style.height = "100%";
|
1980
|
-
videoElement.style.objectFit = "cover";
|
1981
|
-
playerRef.current = videojs(videoElement, options, () => {
|
1982
|
-
onReady(playerRef.current);
|
1983
|
-
});
|
1984
|
-
}
|
1985
|
-
return () => {
|
1986
|
-
var _a2, _b;
|
1987
|
-
if (playerRef.current) {
|
1988
|
-
if (!isEqual((_b = (_a2 = idRef == null ? void 0 : idRef.current) == null ? void 0 : _a2.sources) != null ? _b : "", options.sources)) {
|
1989
|
-
idRef.current = options;
|
1990
|
-
playerRef.current.dispose();
|
1991
|
-
playerRef.current = void 0;
|
1992
|
-
setTimeout(() => {
|
1993
|
-
if (bigPlayButtonRoot[id]) {
|
1994
|
-
bigPlayButtonRoot[id].unmount();
|
1995
|
-
bigPlayButtonRoot[id] = void 0;
|
1996
|
-
}
|
1997
|
-
if (controlBarRoot[id]) {
|
1998
|
-
controlBarRoot[id].unmount();
|
1999
|
-
controlBarRoot[id] = void 0;
|
2000
|
-
}
|
2001
|
-
}, 0);
|
2002
|
-
}
|
2003
|
-
}
|
2004
|
-
};
|
2005
|
-
}, [options]);
|
2006
|
-
useEffect15(() => {
|
2007
|
-
if (playerRef.current) {
|
2008
|
-
playerRef.current.currentTime(startTime);
|
2009
2007
|
}
|
2010
|
-
}
|
2011
|
-
|
2012
|
-
|
2013
|
-
|
2014
|
-
|
2015
|
-
|
2016
|
-
|
2017
|
-
|
2018
|
-
|
2008
|
+
};
|
2009
|
+
}, [options]);
|
2010
|
+
useEffect15(() => {
|
2011
|
+
if (playerRef.current) {
|
2012
|
+
playerRef.current.currentTime(startTime);
|
2013
|
+
}
|
2014
|
+
}, [startTime]);
|
2015
|
+
useEffect15(() => {
|
2016
|
+
if (playerRef.current && isReady) {
|
2017
|
+
const currentTime = playerRef.current.currentTime() || 0;
|
2018
|
+
if (isPaused) {
|
2019
|
+
if (onPause) onPause(currentTime);
|
2020
|
+
} else {
|
2021
|
+
if (onPlay) onPlay(currentTime);
|
2019
2022
|
}
|
2020
|
-
}
|
2021
|
-
|
2022
|
-
|
2023
|
-
|
2023
|
+
}
|
2024
|
+
}, [isPaused]);
|
2025
|
+
useEffect15(() => {
|
2026
|
+
const controlBarTimeout = setTimeout(() => {
|
2027
|
+
renderControlBar(
|
2028
|
+
id,
|
2029
|
+
playerRef.current,
|
2030
|
+
isPaused,
|
2031
|
+
setIsPaused,
|
2032
|
+
duration,
|
2033
|
+
notes,
|
2034
|
+
chapters,
|
2035
|
+
5,
|
2036
|
+
handleSaveNoteAction,
|
2037
|
+
opacity,
|
2038
|
+
(e) => {
|
2039
|
+
handlePlayerClick(e, true);
|
2040
|
+
},
|
2041
|
+
bgColor,
|
2042
|
+
setIsQualityMenuOpen,
|
2043
|
+
setIsSubtitleMenuOpen,
|
2044
|
+
disableNote,
|
2045
|
+
setNoteOpen,
|
2046
|
+
noteButtonClick,
|
2047
|
+
isTrailer
|
2048
|
+
);
|
2049
|
+
}, 0);
|
2050
|
+
return () => clearTimeout(controlBarTimeout);
|
2051
|
+
}, [
|
2052
|
+
isPaused,
|
2053
|
+
setIsPaused,
|
2054
|
+
notes,
|
2055
|
+
handleSaveNoteAction,
|
2056
|
+
duration,
|
2057
|
+
opacity,
|
2058
|
+
isReady,
|
2059
|
+
id,
|
2060
|
+
(_a = playerRef == null ? void 0 : playerRef.current) == null ? void 0 : _a.isFullscreen_
|
2061
|
+
]);
|
2062
|
+
useEffect15(() => {
|
2063
|
+
if (isReady) {
|
2064
|
+
const playButtonTimeout = setTimeout(() => {
|
2065
|
+
renderBigPlayButton(
|
2024
2066
|
id,
|
2025
2067
|
playerRef.current,
|
2026
2068
|
isPaused,
|
2027
2069
|
setIsPaused,
|
2028
|
-
duration,
|
2029
|
-
notes,
|
2030
|
-
chapters,
|
2031
|
-
5,
|
2032
|
-
handleSaveNoteAction,
|
2033
2070
|
opacity,
|
2034
|
-
|
2035
|
-
|
2036
|
-
|
2037
|
-
bgColor,
|
2038
|
-
setIsQualityMenuOpen,
|
2039
|
-
setIsSubtitleMenuOpen,
|
2040
|
-
disableNote,
|
2041
|
-
setNoteOpen,
|
2042
|
-
noteButtonClick,
|
2043
|
-
isTrailer
|
2071
|
+
height,
|
2072
|
+
heightValue,
|
2073
|
+
isLoading
|
2044
2074
|
);
|
2045
|
-
},
|
2046
|
-
return () => clearTimeout(
|
2047
|
-
}
|
2048
|
-
|
2049
|
-
|
2050
|
-
|
2051
|
-
|
2052
|
-
|
2053
|
-
|
2054
|
-
|
2055
|
-
|
2056
|
-
|
2057
|
-
|
2058
|
-
|
2059
|
-
|
2060
|
-
const playButtonTimeout = setTimeout(() => {
|
2061
|
-
renderBigPlayButton(
|
2062
|
-
id,
|
2063
|
-
playerRef.current,
|
2064
|
-
isPaused,
|
2065
|
-
setIsPaused,
|
2066
|
-
opacity,
|
2067
|
-
height,
|
2068
|
-
heightValue,
|
2069
|
-
isLoading
|
2070
|
-
);
|
2071
|
-
}, 500);
|
2072
|
-
return () => clearTimeout(playButtonTimeout);
|
2073
|
-
}
|
2074
|
-
}, [isPaused, opacity, isReady, id, height, heightValue, isLoading]);
|
2075
|
-
useEffect15(() => {
|
2076
|
-
if (playerRef.current) {
|
2077
|
-
const intervalId = setInterval(() => {
|
2078
|
-
if (playerRef.current) setIsPaused(playerRef.current.paused());
|
2079
|
-
}, 500);
|
2080
|
-
return () => clearInterval(intervalId);
|
2081
|
-
}
|
2082
|
-
}, []);
|
2083
|
-
const timeoutRef = useRef2(null);
|
2084
|
-
useEffect15(() => {
|
2085
|
-
if (isQualityMenuOpen || isSubtitleMenuOpen) {
|
2086
|
-
if (timeoutRef.current) {
|
2087
|
-
clearTimeout(timeoutRef.current);
|
2088
|
-
}
|
2089
|
-
setOpacity("100");
|
2090
|
-
} else {
|
2091
|
-
if (timeoutRef.current) {
|
2092
|
-
clearTimeout(timeoutRef.current);
|
2093
|
-
}
|
2094
|
-
setOpacity("0");
|
2095
|
-
timeoutRef.current = setTimeout(() => {
|
2096
|
-
setIsControlBarPresent(false);
|
2097
|
-
}, 3e3);
|
2098
|
-
}
|
2099
|
-
}, [isQualityMenuOpen, isSubtitleMenuOpen]);
|
2100
|
-
useEffect15(() => {
|
2101
|
-
if (isNoteOpen) {
|
2102
|
-
if (timeoutRef.current) {
|
2103
|
-
clearTimeout(timeoutRef.current);
|
2104
|
-
}
|
2105
|
-
} else {
|
2106
|
-
if (timeoutRef.current) {
|
2107
|
-
clearTimeout(timeoutRef.current);
|
2108
|
-
}
|
2109
|
-
timeoutRef.current = setTimeout(() => {
|
2110
|
-
setIsControlBarPresent(false);
|
2111
|
-
}, 3e3);
|
2112
|
-
}
|
2113
|
-
}, [isNoteOpen]);
|
2114
|
-
const handlePlayerClick = async (e, isTimerOnly = false) => {
|
2115
|
-
e.preventDefault();
|
2075
|
+
}, 500);
|
2076
|
+
return () => clearTimeout(playButtonTimeout);
|
2077
|
+
}
|
2078
|
+
}, [isPaused, opacity, isReady, id, height, heightValue, isLoading]);
|
2079
|
+
useEffect15(() => {
|
2080
|
+
if (playerRef.current) {
|
2081
|
+
const intervalId = setInterval(() => {
|
2082
|
+
if (playerRef.current) setIsPaused(playerRef.current.paused());
|
2083
|
+
}, 500);
|
2084
|
+
return () => clearInterval(intervalId);
|
2085
|
+
}
|
2086
|
+
}, []);
|
2087
|
+
const timeoutRef = useRef2(null);
|
2088
|
+
useEffect15(() => {
|
2089
|
+
if (isQualityMenuOpen || isSubtitleMenuOpen) {
|
2116
2090
|
if (timeoutRef.current) {
|
2117
2091
|
clearTimeout(timeoutRef.current);
|
2118
2092
|
}
|
2119
2093
|
setOpacity("100");
|
2120
|
-
|
2094
|
+
} else {
|
2095
|
+
if (timeoutRef.current) {
|
2096
|
+
clearTimeout(timeoutRef.current);
|
2097
|
+
}
|
2098
|
+
setOpacity("0");
|
2121
2099
|
timeoutRef.current = setTimeout(() => {
|
2122
|
-
setOpacity("0");
|
2123
|
-
setBgColor("transparent");
|
2124
2100
|
setIsControlBarPresent(false);
|
2125
2101
|
}, 3e3);
|
2126
|
-
|
2127
|
-
|
2102
|
+
}
|
2103
|
+
}, [isQualityMenuOpen, isSubtitleMenuOpen]);
|
2104
|
+
useEffect15(() => {
|
2105
|
+
if (isNoteOpen) {
|
2106
|
+
if (timeoutRef.current) {
|
2107
|
+
clearTimeout(timeoutRef.current);
|
2128
2108
|
}
|
2129
|
-
|
2130
|
-
|
2109
|
+
} else {
|
2110
|
+
if (timeoutRef.current) {
|
2111
|
+
clearTimeout(timeoutRef.current);
|
2131
2112
|
}
|
2132
|
-
|
2133
|
-
|
2134
|
-
|
2135
|
-
|
2136
|
-
|
2137
|
-
|
2138
|
-
|
2139
|
-
|
2140
|
-
|
2141
|
-
|
2142
|
-
|
2143
|
-
|
2113
|
+
timeoutRef.current = setTimeout(() => {
|
2114
|
+
setIsControlBarPresent(false);
|
2115
|
+
}, 3e3);
|
2116
|
+
}
|
2117
|
+
}, [isNoteOpen]);
|
2118
|
+
const handlePlayerClick = async (e, isTimerOnly = false) => {
|
2119
|
+
e.preventDefault();
|
2120
|
+
if (timeoutRef.current) {
|
2121
|
+
clearTimeout(timeoutRef.current);
|
2122
|
+
}
|
2123
|
+
setOpacity("100");
|
2124
|
+
setIsControlBarPresent(true);
|
2125
|
+
timeoutRef.current = setTimeout(() => {
|
2126
|
+
setOpacity("0");
|
2127
|
+
setBgColor("transparent");
|
2128
|
+
setIsControlBarPresent(false);
|
2129
|
+
}, 3e3);
|
2130
|
+
if (isTimerOnly) {
|
2131
|
+
return;
|
2132
|
+
}
|
2133
|
+
if (!isControlBarPresent) {
|
2134
|
+
return;
|
2135
|
+
}
|
2136
|
+
if (playerRef.current) {
|
2137
|
+
if (playerRef.current.paused()) {
|
2138
|
+
try {
|
2139
|
+
await playerRef.current.play();
|
2140
|
+
setIsPaused(false);
|
2141
|
+
} catch (error) {
|
2142
|
+
console.error("Failed to play video:", error);
|
2144
2143
|
}
|
2144
|
+
} else {
|
2145
|
+
playerRef.current.pause();
|
2146
|
+
setIsPaused(true);
|
2147
|
+
if (onPause) onPause(playerRef.current.currentTime() || 0);
|
2145
2148
|
}
|
2146
|
-
}
|
2147
|
-
|
2148
|
-
|
2149
|
-
|
2150
|
-
|
2151
|
-
|
2152
|
-
|
2153
|
-
|
2154
|
-
|
2155
|
-
|
2156
|
-
|
2157
|
-
|
2158
|
-
|
2159
|
-
|
2160
|
-
|
2149
|
+
}
|
2150
|
+
};
|
2151
|
+
const videoRefs = useRef2(null);
|
2152
|
+
useEffect15(() => {
|
2153
|
+
const observer = new IntersectionObserver(
|
2154
|
+
(entries) => {
|
2155
|
+
entries.forEach((entry) => {
|
2156
|
+
var _a2, _b;
|
2157
|
+
if (entry.isIntersecting === false) {
|
2158
|
+
if (((_a2 = playerRef == null ? void 0 : playerRef.current) == null ? void 0 : _a2.paused()) === false) {
|
2159
|
+
try {
|
2160
|
+
(_b = playerRef == null ? void 0 : playerRef.current) == null ? void 0 : _b.pause();
|
2161
|
+
setIsPaused(true);
|
2162
|
+
} catch (error) {
|
2163
|
+
console.error("Failed to play video:", error);
|
2161
2164
|
}
|
2162
2165
|
}
|
2163
|
-
}
|
2164
|
-
}
|
2165
|
-
|
2166
|
-
|
2167
|
-
|
2168
|
-
|
2169
|
-
|
2166
|
+
}
|
2167
|
+
});
|
2168
|
+
},
|
2169
|
+
{
|
2170
|
+
threshold: 0.1
|
2171
|
+
// The amount of the component that must be visible (0.1 means 10% visible)
|
2172
|
+
}
|
2173
|
+
);
|
2174
|
+
if (videoRefs.current) {
|
2175
|
+
observer.observe(videoRefs.current);
|
2176
|
+
}
|
2177
|
+
return () => {
|
2170
2178
|
if (videoRefs.current) {
|
2171
|
-
observer.
|
2179
|
+
observer.unobserve(videoRef.current);
|
2172
2180
|
}
|
2173
|
-
|
2174
|
-
|
2175
|
-
|
2176
|
-
|
2177
|
-
|
2178
|
-
|
2179
|
-
|
2180
|
-
|
2181
|
-
|
2182
|
-
|
2183
|
-
|
2184
|
-
|
2185
|
-
if (duration2 && currentTime !== void 0) {
|
2186
|
-
setTimeSeeker(`${currentTime / duration2 * 100}%`);
|
2187
|
-
} else {
|
2188
|
-
setTimeSeeker("0");
|
2189
|
-
}
|
2181
|
+
};
|
2182
|
+
}, []);
|
2183
|
+
const [timeSeeker, setTimeSeeker] = useState14("0");
|
2184
|
+
useEffect15(() => {
|
2185
|
+
const updateTimeSeeker = () => {
|
2186
|
+
if (playerRef.current && isReady) {
|
2187
|
+
const currentTime = playerRef.current.currentTime();
|
2188
|
+
const duration2 = playerRef.current.duration();
|
2189
|
+
if (duration2 && currentTime !== void 0) {
|
2190
|
+
setTimeSeeker(`${currentTime / duration2 * 100}%`);
|
2191
|
+
} else {
|
2192
|
+
setTimeSeeker("0");
|
2190
2193
|
}
|
2191
|
-
}
|
2192
|
-
|
2193
|
-
|
2194
|
-
|
2195
|
-
|
2196
|
-
|
2197
|
-
|
2194
|
+
}
|
2195
|
+
};
|
2196
|
+
const interval = setInterval(updateTimeSeeker, 500);
|
2197
|
+
return () => clearInterval(interval);
|
2198
|
+
}, [playerRef]);
|
2199
|
+
const container = document.getElementById(`video-container-${id}`);
|
2200
|
+
function handleWidthChange(height2) {
|
2201
|
+
setHeightValue(height2);
|
2202
|
+
}
|
2203
|
+
const resizeObserver = new ResizeObserver((entries) => {
|
2204
|
+
for (let entry of entries) {
|
2205
|
+
const currentHeight = entry.contentRect.height;
|
2206
|
+
handleWidthChange(currentHeight);
|
2198
2207
|
}
|
2199
|
-
|
2200
|
-
|
2201
|
-
|
2202
|
-
|
2208
|
+
});
|
2209
|
+
const controlBar = container == null ? void 0 : container.querySelector(".vjs-control-bar");
|
2210
|
+
if (controlBar) {
|
2211
|
+
resizeObserver.observe(controlBar);
|
2212
|
+
}
|
2213
|
+
function debounce(func, delay) {
|
2214
|
+
let timeoutId;
|
2215
|
+
return function(arg) {
|
2216
|
+
if (timeoutId) {
|
2217
|
+
clearTimeout(timeoutId);
|
2203
2218
|
}
|
2219
|
+
timeoutId = setTimeout(() => {
|
2220
|
+
func(arg);
|
2221
|
+
}, delay);
|
2222
|
+
};
|
2223
|
+
}
|
2224
|
+
if (playerRef.current) {
|
2225
|
+
playerRef.current.on("waiting", function() {
|
2226
|
+
debounce((arg) => setIsloading(arg), 300)(true);
|
2204
2227
|
});
|
2205
|
-
|
2206
|
-
|
2207
|
-
|
2208
|
-
|
2209
|
-
|
2210
|
-
|
2211
|
-
|
2212
|
-
|
2213
|
-
|
2228
|
+
playerRef.current.on("playing", function() {
|
2229
|
+
debounce((arg) => setIsloading(arg), 300)(false);
|
2230
|
+
});
|
2231
|
+
}
|
2232
|
+
return /* @__PURE__ */ jsx41(Fragment4, { children: /* @__PURE__ */ jsx41(
|
2233
|
+
Suspense,
|
2234
|
+
{
|
2235
|
+
fallback: /* @__PURE__ */ jsx41(SkillamiIcon_default, { className: " sb-w-16 sb-h-16 sb-animate-spin sb-absolute -sb-top-2 -sb-right-2 " }),
|
2236
|
+
children: /* @__PURE__ */ jsxs19(
|
2237
|
+
"div",
|
2238
|
+
{
|
2239
|
+
ref: videoRefs,
|
2240
|
+
id: `video-container-${id}`,
|
2241
|
+
onMouseMove: () => {
|
2242
|
+
!isNoteOpen ? handlePlayerClick(event, true) : "";
|
2243
|
+
},
|
2244
|
+
className: "sb-relative sb-rounded-md sb-overflow-hidden sb-w-full sb-h-full sb-bottom-2 ",
|
2245
|
+
onMouseEnter: () => setIsHovered(true),
|
2246
|
+
onMouseLeave: () => setIsHovered(false),
|
2247
|
+
children: [
|
2248
|
+
bottomRedBar && /* @__PURE__ */ jsx41(
|
2249
|
+
"div",
|
2250
|
+
{
|
2251
|
+
ref: childRef,
|
2252
|
+
onClick: handlePlayerClick,
|
2253
|
+
className: `sb-h-[3px] sb-transition-opacity sb-duration-500 sb-delay-400 sb-z-10 ease-in-out sb-border-spacing-x-2 sb-absolute sb-bg-[red] sb-bottom-0 ${opacity == "100" ? "sb-opacity-0" : "sb-opacity-100"}`,
|
2254
|
+
style: {
|
2255
|
+
width: timeSeeker
|
2256
|
+
}
|
2257
|
+
}
|
2258
|
+
),
|
2259
|
+
/* @__PURE__ */ jsx41(
|
2260
|
+
"div",
|
2261
|
+
{
|
2262
|
+
className: "hover:sb-cursor-pointer sb-w-full sb-h-full",
|
2263
|
+
"data-vjs-player": true,
|
2264
|
+
children: /* @__PURE__ */ jsx41(
|
2265
|
+
"div",
|
2266
|
+
{
|
2267
|
+
onClick: handlePlayerClick,
|
2268
|
+
ref: videoRef,
|
2269
|
+
className: "sb-h-full sb-w-full sb-relative"
|
2270
|
+
}
|
2271
|
+
)
|
2272
|
+
}
|
2273
|
+
)
|
2274
|
+
]
|
2214
2275
|
}
|
2215
|
-
|
2216
|
-
func(arg);
|
2217
|
-
}, delay);
|
2218
|
-
};
|
2219
|
-
}
|
2220
|
-
if (playerRef.current) {
|
2221
|
-
playerRef.current.on("waiting", function() {
|
2222
|
-
debounce((arg) => setIsloading(arg), 300)(true);
|
2223
|
-
});
|
2224
|
-
playerRef.current.on("playing", function() {
|
2225
|
-
debounce((arg) => setIsloading(arg), 300)(false);
|
2226
|
-
});
|
2276
|
+
)
|
2227
2277
|
}
|
2228
|
-
|
2229
|
-
|
2230
|
-
{
|
2231
|
-
fallback: /* @__PURE__ */ jsx41(SkillamiIcon_default, { className: " sb-w-16 sb-h-16 sb-animate-spin sb-absolute -sb-top-2 -sb-right-2 " }),
|
2232
|
-
children: /* @__PURE__ */ jsxs19(
|
2233
|
-
"div",
|
2234
|
-
{
|
2235
|
-
ref: videoRefs,
|
2236
|
-
id: `video-container-${id}`,
|
2237
|
-
onMouseMove: () => {
|
2238
|
-
!isNoteOpen ? handlePlayerClick(event, true) : "";
|
2239
|
-
},
|
2240
|
-
className: "sb-relative sb-rounded-md sb-overflow-hidden sb-w-full sb-h-full sb-bottom-2 ",
|
2241
|
-
onMouseEnter: () => setIsHovered(true),
|
2242
|
-
onMouseLeave: () => setIsHovered(false),
|
2243
|
-
children: [
|
2244
|
-
bottomRedBar && /* @__PURE__ */ jsx41(
|
2245
|
-
"div",
|
2246
|
-
{
|
2247
|
-
ref: childRef,
|
2248
|
-
onClick: handlePlayerClick,
|
2249
|
-
className: `sb-h-[3px] sb-transition-opacity sb-duration-500 sb-delay-400 sb-z-10 ease-in-out sb-border-spacing-x-2 sb-absolute sb-bg-[red] sb-bottom-0 ${opacity == "100" ? "sb-opacity-0" : "sb-opacity-100"}`,
|
2250
|
-
style: {
|
2251
|
-
width: timeSeeker
|
2252
|
-
}
|
2253
|
-
}
|
2254
|
-
),
|
2255
|
-
/* @__PURE__ */ jsx41(
|
2256
|
-
"div",
|
2257
|
-
{
|
2258
|
-
className: "hover:sb-cursor-pointer sb-w-full sb-h-full",
|
2259
|
-
"data-vjs-player": true,
|
2260
|
-
children: /* @__PURE__ */ jsx41(
|
2261
|
-
"div",
|
2262
|
-
{
|
2263
|
-
onClick: handlePlayerClick,
|
2264
|
-
ref: videoRef,
|
2265
|
-
className: "sb-h-full sb-w-full sb-relative"
|
2266
|
-
}
|
2267
|
-
)
|
2268
|
-
}
|
2269
|
-
)
|
2270
|
-
]
|
2271
|
-
}
|
2272
|
-
)
|
2273
|
-
}
|
2274
|
-
) });
|
2275
|
-
}
|
2276
|
-
);
|
2278
|
+
) });
|
2279
|
+
};
|
2277
2280
|
var VideoPlayerComponent_default = VideoPlayerComponent;
|
2278
2281
|
|
2279
2282
|
// src/components/SoftBuildersVideoPlayer/index.tsx
|
@@ -2290,87 +2293,86 @@ var DEFAULT_OPTIONS = {
|
|
2290
2293
|
sources: [],
|
2291
2294
|
tracks: []
|
2292
2295
|
};
|
2293
|
-
var Component =
|
2294
|
-
|
2295
|
-
|
2296
|
-
|
2297
|
-
|
2298
|
-
|
2299
|
-
|
2300
|
-
|
2301
|
-
|
2302
|
-
|
2303
|
-
|
2304
|
-
|
2305
|
-
|
2306
|
-
|
2307
|
-
|
2308
|
-
|
2309
|
-
|
2310
|
-
})
|
2311
|
-
|
2312
|
-
|
2313
|
-
|
2314
|
-
|
2315
|
-
|
2316
|
-
|
2317
|
-
|
2318
|
-
|
2319
|
-
|
2320
|
-
|
2321
|
-
|
2322
|
-
|
2323
|
-
|
2324
|
-
|
2325
|
-
|
2326
|
-
|
2327
|
-
|
2328
|
-
|
2329
|
-
|
2330
|
-
const
|
2331
|
-
|
2332
|
-
|
2333
|
-
|
2334
|
-
|
2335
|
-
|
2336
|
-
src = await convertSRTtoVTT(s.src);
|
2337
|
-
}
|
2338
|
-
newTracks.push(__spreadProps(__spreadValues({}, s), {
|
2339
|
-
src
|
2340
|
-
}));
|
2296
|
+
var Component = ({
|
2297
|
+
options,
|
2298
|
+
notes,
|
2299
|
+
chapters,
|
2300
|
+
startTime = 0,
|
2301
|
+
handleSaveNoteAction,
|
2302
|
+
onPlay,
|
2303
|
+
onPause,
|
2304
|
+
isFocused = true,
|
2305
|
+
disableNote,
|
2306
|
+
childRef,
|
2307
|
+
bottomRedBar,
|
2308
|
+
noteButtonClick,
|
2309
|
+
videoId,
|
2310
|
+
isTrailer = false,
|
2311
|
+
height
|
2312
|
+
}) => {
|
2313
|
+
options = __spreadProps(__spreadValues({}, options), {
|
2314
|
+
responsive: true,
|
2315
|
+
inactivityTimeout: 0,
|
2316
|
+
fullscreen: {
|
2317
|
+
navigationUI: "hide"
|
2318
|
+
}
|
2319
|
+
});
|
2320
|
+
if (options.autoplay === void 0)
|
2321
|
+
options.autoplay = DEFAULT_OPTIONS.autoplay;
|
2322
|
+
if (options.controls === void 0)
|
2323
|
+
options.controls = DEFAULT_OPTIONS.controls;
|
2324
|
+
if (options.fluid === void 0) options.fluid = DEFAULT_OPTIONS.fluid;
|
2325
|
+
if ((options == null ? void 0 : options.muted) === void 0) options.muted = DEFAULT_OPTIONS == null ? void 0 : DEFAULT_OPTIONS.muted;
|
2326
|
+
if (options.height === void 0) options.height = DEFAULT_OPTIONS.height;
|
2327
|
+
if (options.width === void 0) options.width = DEFAULT_OPTIONS.width;
|
2328
|
+
const [tracks, setTracks] = useState15([]);
|
2329
|
+
useEffect16(() => {
|
2330
|
+
}, [isFocused]);
|
2331
|
+
useEffect16(() => {
|
2332
|
+
const getTracks = async () => {
|
2333
|
+
const newTracks = [];
|
2334
|
+
if (Array.isArray(options == null ? void 0 : options.tracks)) {
|
2335
|
+
for (const [i, s] of options == null ? void 0 : options.tracks.entries()) {
|
2336
|
+
let src = s.src;
|
2337
|
+
if (s.memeType == "text/srt") {
|
2338
|
+
src = await convertSRTtoVTT(s.src);
|
2341
2339
|
}
|
2342
|
-
|
2343
|
-
|
2344
|
-
|
2345
|
-
|
2346
|
-
console.log("options:===. ", options);
|
2347
|
-
const id = (Date.now() + Math.random() * 100).toString();
|
2348
|
-
const [uuid, setUuid] = useState15("");
|
2349
|
-
useEffect16(() => {
|
2350
|
-
setUuid(uuidv4());
|
2351
|
-
}, []);
|
2352
|
-
return /* @__PURE__ */ jsx42(
|
2353
|
-
VideoPlayerComponent_default,
|
2354
|
-
{
|
2355
|
-
id: uuid,
|
2356
|
-
chapters,
|
2357
|
-
options: __spreadProps(__spreadValues({}, options), { tracks }),
|
2358
|
-
notes,
|
2359
|
-
poster: "",
|
2360
|
-
startTime,
|
2361
|
-
handleSaveNoteAction,
|
2362
|
-
disableNote,
|
2363
|
-
onPause,
|
2364
|
-
onPlay,
|
2365
|
-
childRef,
|
2366
|
-
bottomRedBar,
|
2367
|
-
noteButtonClick,
|
2368
|
-
isTrailer,
|
2369
|
-
height
|
2340
|
+
newTracks.push(__spreadProps(__spreadValues({}, s), {
|
2341
|
+
src
|
2342
|
+
}));
|
2343
|
+
}
|
2370
2344
|
}
|
2371
|
-
|
2372
|
-
|
2373
|
-
);
|
2345
|
+
setTracks(newTracks);
|
2346
|
+
};
|
2347
|
+
getTracks();
|
2348
|
+
}, [options == null ? void 0 : options.tracks]);
|
2349
|
+
console.log("options:===. ", options);
|
2350
|
+
const id = (Date.now() + Math.random() * 100).toString();
|
2351
|
+
const [uuid, setUuid] = useState15("");
|
2352
|
+
useEffect16(() => {
|
2353
|
+
setUuid(uuidv4());
|
2354
|
+
}, []);
|
2355
|
+
return /* @__PURE__ */ jsx42(
|
2356
|
+
VideoPlayerComponent_default,
|
2357
|
+
{
|
2358
|
+
id: uuid,
|
2359
|
+
chapters,
|
2360
|
+
options: __spreadProps(__spreadValues({}, options), { tracks }),
|
2361
|
+
notes,
|
2362
|
+
poster: "",
|
2363
|
+
startTime,
|
2364
|
+
handleSaveNoteAction,
|
2365
|
+
disableNote,
|
2366
|
+
onPause,
|
2367
|
+
onPlay,
|
2368
|
+
childRef,
|
2369
|
+
bottomRedBar,
|
2370
|
+
noteButtonClick,
|
2371
|
+
isTrailer,
|
2372
|
+
height
|
2373
|
+
}
|
2374
|
+
);
|
2375
|
+
};
|
2374
2376
|
var SoftBuildersVideoPlayer = memo(Component, (prevProps, nextProps) => {
|
2375
2377
|
return isEqual2(prevProps.options, nextProps.options) && prevProps.options.sources[0].type === nextProps.options.sources[0].type && prevProps.notes === nextProps.notes && prevProps.chapters === nextProps.chapters && prevProps.startTime === nextProps.startTime && prevProps.height === nextProps.height;
|
2376
2378
|
});
|