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/index.mjs CHANGED
@@ -31,11 +31,10 @@ var __objRest = (source, exclude) => {
31
31
  };
32
32
 
33
33
  // src/components/SoftBuildersVideoPlayer/index.tsx
34
- import { forwardRef as forwardRef2, memo, useEffect as useEffect16, useState as useState15 } from "react";
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
- const qualityLevels = player == null ? void 0 : player.qualityLevels();
914
- setQualities(qualityLevels.levels_);
915
- console.log("qualityLevels.levels_: ", qualityLevels.levels_.length);
916
- setQualities((pre) => [...pre, { width: "auto", height: "auto" }]);
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 = forwardRef(
1877
- ({
1878
- id,
1879
- options,
1880
- notes,
1881
- chapters,
1882
- startTime = 0,
1883
- handleSaveNoteAction,
1884
- poster,
1885
- onPlay,
1886
- onPause,
1887
- disableNote,
1888
- childRef,
1889
- bottomRedBar = true,
1890
- noteButtonClick,
1891
- videoID,
1892
- isTrailer,
1893
- height
1894
- }, ref) => {
1895
- var _a;
1896
- const videoRef = useRef2(void 0);
1897
- const playerRef = useRef2(void 0);
1898
- const idRef = useRef2(void 0);
1899
- const [isReady, setIsReady] = useState14(false);
1900
- const [isPaused, setIsPaused] = useState14(!options.autoplay);
1901
- const [duration, setDuration] = useState14(1);
1902
- const [opacity, setOpacity] = useState14("0");
1903
- const [isControlBarPresent, setIsControlBarPresent] = useState14(true);
1904
- const [bgColor, setBgColor] = useState14("transparent");
1905
- const [isQualityMenuOpen, setIsQualityMenuOpen] = useState14(false);
1906
- const [isSubtitleMenuOpen, setIsSubtitleMenuOpen] = useState14(false);
1907
- const [isHovered, setIsHovered] = useState14(false);
1908
- const [isNoteOpen, setNoteOpen] = useState14(false);
1909
- const [heightValue, setHeightValue] = useState14(0);
1910
- const [isLoading, setIsloading] = useState14(false);
1911
- const onReady = (player) => {
1912
- if (playerRef) {
1913
- playerRef.current = player;
1914
- setIsReady(true);
1915
- player == null ? void 0 : player.currentTime(startTime);
1916
- player.on("waiting", () => {
1917
- });
1918
- player.on("dispose", () => {
1919
- videojs.log("player will dispose");
1920
- setIsReady(false);
1921
- });
1922
- player.on("loadedmetadata", () => {
1923
- const d = player.duration() || 0;
1924
- setDuration(d);
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
- useEffect15(() => {
1929
- if (!playerRef.current) {
1930
- const videoElement = document.createElement("video-js");
1931
- videoElement.setAttribute("playsinline", "true");
1932
- videoElement.classList.add("vjs-big-play-centered");
1933
- if (poster) {
1934
- videoElement.setAttribute("poster", poster);
1935
- }
1936
- videoRef.current.appendChild(videoElement);
1937
- videoElement.style.width = "100%";
1938
- videoElement.style.height = "100%";
1939
- videoElement.style.objectFit = "cover";
1940
- playerRef.current = videojs(videoElement, options, () => {
1941
- onReady(playerRef.current);
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
- return () => {
1945
- if (playerRef.current) {
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
- }, [startTime]);
2011
- useEffect15(() => {
2012
- if (playerRef.current && isReady) {
2013
- const currentTime = playerRef.current.currentTime() || 0;
2014
- if (isPaused) {
2015
- if (onPause) onPause(currentTime);
2016
- } else {
2017
- if (onPlay) onPlay(currentTime);
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
- }, [isPaused]);
2021
- useEffect15(() => {
2022
- const controlBarTimeout = setTimeout(() => {
2023
- renderControlBar(
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
- (e) => {
2035
- handlePlayerClick(e, true);
2036
- },
2037
- bgColor,
2038
- setIsQualityMenuOpen,
2039
- setIsSubtitleMenuOpen,
2040
- disableNote,
2041
- setNoteOpen,
2042
- noteButtonClick,
2043
- isTrailer
2071
+ height,
2072
+ heightValue,
2073
+ isLoading
2044
2074
  );
2045
- }, 0);
2046
- return () => clearTimeout(controlBarTimeout);
2047
- }, [
2048
- isPaused,
2049
- setIsPaused,
2050
- notes,
2051
- handleSaveNoteAction,
2052
- duration,
2053
- opacity,
2054
- isReady,
2055
- id,
2056
- (_a = playerRef == null ? void 0 : playerRef.current) == null ? void 0 : _a.isFullscreen_
2057
- ]);
2058
- useEffect15(() => {
2059
- if (isReady) {
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
- setIsControlBarPresent(true);
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
- if (isTimerOnly) {
2127
- return;
2102
+ }
2103
+ }, [isQualityMenuOpen, isSubtitleMenuOpen]);
2104
+ useEffect15(() => {
2105
+ if (isNoteOpen) {
2106
+ if (timeoutRef.current) {
2107
+ clearTimeout(timeoutRef.current);
2128
2108
  }
2129
- if (!isControlBarPresent) {
2130
- return;
2109
+ } else {
2110
+ if (timeoutRef.current) {
2111
+ clearTimeout(timeoutRef.current);
2131
2112
  }
2132
- if (playerRef.current) {
2133
- if (playerRef.current.paused()) {
2134
- try {
2135
- await playerRef.current.play();
2136
- setIsPaused(false);
2137
- } catch (error) {
2138
- console.error("Failed to play video:", error);
2139
- }
2140
- } else {
2141
- playerRef.current.pause();
2142
- setIsPaused(true);
2143
- if (onPause) onPause(playerRef.current.currentTime() || 0);
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
- const videoRefs = useRef2(null);
2148
- useEffect15(() => {
2149
- const observer = new IntersectionObserver(
2150
- (entries) => {
2151
- entries.forEach((entry) => {
2152
- var _a2, _b;
2153
- if (entry.isIntersecting === false) {
2154
- if (((_a2 = playerRef == null ? void 0 : playerRef.current) == null ? void 0 : _a2.paused()) === false) {
2155
- try {
2156
- (_b = playerRef == null ? void 0 : playerRef.current) == null ? void 0 : _b.pause();
2157
- setIsPaused(true);
2158
- } catch (error) {
2159
- console.error("Failed to play video:", error);
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
- threshold: 0.1
2167
- // The amount of the component that must be visible (0.1 means 10% visible)
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.observe(videoRefs.current);
2179
+ observer.unobserve(videoRef.current);
2172
2180
  }
2173
- return () => {
2174
- if (videoRefs.current) {
2175
- observer.unobserve(videoRef.current);
2176
- }
2177
- };
2178
- }, []);
2179
- const [timeSeeker, setTimeSeeker] = useState14("0");
2180
- useEffect15(() => {
2181
- const updateTimeSeeker = () => {
2182
- if (playerRef.current && isReady) {
2183
- const currentTime = playerRef.current.currentTime();
2184
- const duration2 = playerRef.current.duration();
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
- const interval = setInterval(updateTimeSeeker, 500);
2193
- return () => clearInterval(interval);
2194
- }, [playerRef]);
2195
- const container = document.getElementById(`video-container-${id}`);
2196
- function handleWidthChange(height2) {
2197
- setHeightValue(height2);
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
- const resizeObserver = new ResizeObserver((entries) => {
2200
- for (let entry of entries) {
2201
- const currentHeight = entry.contentRect.height;
2202
- handleWidthChange(currentHeight);
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
- const controlBar = container == null ? void 0 : container.querySelector(".vjs-control-bar");
2206
- if (controlBar) {
2207
- resizeObserver.observe(controlBar);
2208
- }
2209
- function debounce(func, delay) {
2210
- let timeoutId;
2211
- return function(arg) {
2212
- if (timeoutId) {
2213
- clearTimeout(timeoutId);
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
- timeoutId = setTimeout(() => {
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
- return /* @__PURE__ */ jsx41(Fragment4, { children: /* @__PURE__ */ jsx41(
2229
- Suspense,
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 = forwardRef2(
2294
- ({
2295
- options,
2296
- notes,
2297
- chapters,
2298
- startTime = 0,
2299
- handleSaveNoteAction,
2300
- onPlay,
2301
- onPause,
2302
- isFocused = true,
2303
- disableNote,
2304
- childRef,
2305
- bottomRedBar,
2306
- noteButtonClick,
2307
- videoId,
2308
- isTrailer = false,
2309
- height
2310
- }) => {
2311
- options = __spreadProps(__spreadValues({}, options), {
2312
- responsive: true,
2313
- inactivityTimeout: 0,
2314
- fullscreen: {
2315
- navigationUI: "hide"
2316
- }
2317
- });
2318
- if (options.autoplay === void 0)
2319
- options.autoplay = DEFAULT_OPTIONS.autoplay;
2320
- if (options.controls === void 0)
2321
- options.controls = DEFAULT_OPTIONS.controls;
2322
- if (options.fluid === void 0) options.fluid = DEFAULT_OPTIONS.fluid;
2323
- if ((options == null ? void 0 : options.muted) === void 0) options.muted = DEFAULT_OPTIONS == null ? void 0 : DEFAULT_OPTIONS.muted;
2324
- if (options.height === void 0) options.height = DEFAULT_OPTIONS.height;
2325
- if (options.width === void 0) options.width = DEFAULT_OPTIONS.width;
2326
- const [tracks, setTracks] = useState15([]);
2327
- useEffect16(() => {
2328
- }, [isFocused]);
2329
- useEffect16(() => {
2330
- const getTracks = async () => {
2331
- const newTracks = [];
2332
- if (Array.isArray(options == null ? void 0 : options.tracks))
2333
- for (const [i, s] of options == null ? void 0 : options.tracks.entries()) {
2334
- let src = s.src;
2335
- if (s.memeType == "text/srt") {
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
- setTracks(newTracks);
2343
- };
2344
- getTracks();
2345
- }, [options == null ? void 0 : options.tracks]);
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
  });