zarebin-player-library 1.1.1 → 1.1.3

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.
@@ -12728,8 +12728,9 @@ var useGetMarkers = () => {
12728
12728
  var useGetPlayList = () => {
12729
12729
  const dispatch = useAppDispatch();
12730
12730
  const { isFetchDetails } = useAppSelector(({ videoData: { isFetchDetails } }) => ({ isFetchDetails }), shallowEqual);
12731
+ const { loadedFragmentsCount } = useAppSelector(({ controller: { loadedFragmentsCount } }) => ({ loadedFragmentsCount }), shallowEqual);
12731
12732
  useEffect(() => {
12732
- if (conditions(ConditionName.getPlayList)) {
12733
+ if (conditions(ConditionName.getPlayList) && conditions(ConditionName.hasPermittedLoadedFragment)) {
12733
12734
  const handleGetPlayList = async () => {
12734
12735
  const { data, status } = await getPlaylistHeader(API().playList);
12735
12736
  if (responseValidator(status)) {
@@ -12747,7 +12748,7 @@ var useGetPlayList = () => {
12747
12748
  };
12748
12749
  handleGetPlayList();
12749
12750
  }
12750
- }, [isFetchDetails]);
12751
+ }, [isFetchDetails, loadedFragmentsCount.length]);
12751
12752
  };
12752
12753
  //#endregion
12753
12754
  //#region src/videoPlayerLibrary/shared/helpers/hooks/useGetData/useGetProfile.tsx
@@ -12796,12 +12797,13 @@ var useGetRecommendationList = () => {
12796
12797
  isFetchDetails,
12797
12798
  params
12798
12799
  }), shallowEqual);
12800
+ const { loadedFragmentsCount } = useAppSelector(({ controller: { loadedFragmentsCount } }) => ({ loadedFragmentsCount }), shallowEqual);
12799
12801
  useEffect(() => {
12800
- if (conditions(ConditionName.getRecommendationList)) (async () => {
12802
+ if (conditions(ConditionName.getRecommendationList) && conditions(ConditionName.hasPermittedLoadedFragment)) (async () => {
12801
12803
  const { data, status } = await apiCaller({ url: API().recommendationList() });
12802
12804
  if (responseValidator(status)) dispatch(setRecommendationList(data));
12803
12805
  })();
12804
- }, [isFetchDetails]);
12806
+ }, [isFetchDetails, loadedFragmentsCount.length]);
12805
12807
  };
12806
12808
  //#endregion
12807
12809
  //#region src/videoPlayerLibrary/shared/helpers/hooks/useGetData/useUserSettings.tsx
@@ -20530,7 +20532,7 @@ var RangeControl = class extends Component {
20530
20532
  * @group ControlBar
20531
20533
  * @since 4.0.0
20532
20534
  */
20533
- var ProgressBar$2 = class extends ControlBarItem {
20535
+ var ProgressBar$1 = class extends ControlBarItem {
20534
20536
  get element() {
20535
20537
  return this._rangeControl.rootEl;
20536
20538
  }
@@ -21684,7 +21686,7 @@ var ControlBar = class ControlBar {
21684
21686
  }
21685
21687
  _createDefaultItems() {
21686
21688
  const items = [];
21687
- if (this.progressBar) items.push(new ProgressBar$2(getObjectOption(this.progressBar)));
21689
+ if (this.progressBar) items.push(new ProgressBar$1(getObjectOption(this.progressBar)));
21688
21690
  if (this.playButton) items.push(new PlayButton(getObjectOption(this.playButton)));
21689
21691
  if (this.volumeButton) items.push(new VolumeControl(getObjectOption(this.volumeButton)));
21690
21692
  if (this.gyroButton) items.push(new GyroButton(getObjectOption(this.gyroButton)));
@@ -65336,7 +65338,7 @@ var ViewersChart = () => {
65336
65338
  var viewersChart_default = memo(ViewersChart);
65337
65339
  //#endregion
65338
65340
  //#region src/videoPlayerLibrary/shared/ui/src/components/mainComponent/footer/progressbar/progressbar.tsx
65339
- var ProgressBar$1 = () => {
65341
+ var ProgressBar = () => {
65340
65342
  const [isPointerDown, setIsPointerDown] = useState(false);
65341
65343
  useEffect(() => {
65342
65344
  hideProgressTooltip(document.querySelector(".progressTooltip"));
@@ -68266,7 +68268,7 @@ var Footer = () => {
68266
68268
  paddingLeft: footerPadding(),
68267
68269
  paddingRight: footerPadding()
68268
68270
  },
68269
- children: [conditions(ConditionName.showProgressbar) && conditions(ConditionName.hasTimeMachine) && /* @__PURE__ */ jsx(ProgressBar$1, {}), /* @__PURE__ */ jsx(controllbar_default, {})]
68271
+ children: [conditions(ConditionName.showProgressbar) && conditions(ConditionName.hasTimeMachine) && /* @__PURE__ */ jsx(ProgressBar, {}), /* @__PURE__ */ jsx(controllbar_default, {})]
68270
68272
  }), conditions(ConditionName.showInstagramEmoji) && /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(InstagramEmoji, {}) })] })
68271
68273
  ]
68272
68274
  });
@@ -68887,309 +68889,6 @@ var ContinuousPlayback = () => {
68887
68889
  });
68888
68890
  };
68889
68891
  //#endregion
68890
- //#region src/videoPlayerLibrary/shared/ui/src/components/advertisement/hooks/useControlsVisibility.ts
68891
- var useControlsVisibility = (isPaused) => {
68892
- const [showControls, setShowControls] = useState(true);
68893
- const timeoutRef = useRef(null);
68894
- return {
68895
- showControls,
68896
- resetTimer: useCallback((delay = activeElementsTime) => {
68897
- if (isPaused) return setShowControls(true);
68898
- setShowControls(true);
68899
- if (timeoutRef.current) clearTimeout(timeoutRef.current);
68900
- timeoutRef.current = setTimeout(() => setShowControls(false), delay);
68901
- }, [isPaused])
68902
- };
68903
- };
68904
- //#endregion
68905
- //#region src/videoPlayerLibrary/shared/ui/src/components/advertisement/hooks/useVideoControls.ts
68906
- var useVideoControls = (ad, params) => {
68907
- const dispatch = useAppDispatch();
68908
- const [progress, setProgress] = useState(0);
68909
- const [buffered, setBuffered] = useState(0);
68910
- const [currentTime, setCurrentTime] = useState(0);
68911
- const [duration, setDuration] = useState(0);
68912
- const [isPaused, setIsPaused] = useState(false);
68913
- const [firstPlay, setFirstPlay] = useState(true);
68914
- const firstPlayRef = useRef(firstPlay);
68915
- useEffect(() => {
68916
- firstPlayRef.current = firstPlay;
68917
- }, [firstPlay]);
68918
- const hasSkip = Boolean(ad?.mandatory_play_time && ad.mandatory_play_time > 0);
68919
- const [skipCounter, setSkipCounter] = useState(hasSkip ? ad.mandatory_play_time : null);
68920
- const [isCounting, setIsCounting] = useState(false);
68921
- useEffect(() => {
68922
- if (!hasSkip || !isCounting) return;
68923
- const interval = setInterval(() => {
68924
- setSkipCounter((prev) => prev && prev > 1 ? prev - 1 : 0);
68925
- }, 1e3);
68926
- return () => clearInterval(interval);
68927
- }, [hasSkip, isCounting]);
68928
- useEffect(() => {
68929
- const video = videoTag();
68930
- if (!video) return;
68931
- const handlePlay = () => {
68932
- setIsCounting(true);
68933
- setIsPaused(false);
68934
- if (firstPlayRef.current) {
68935
- params.ad.onAdView(ad);
68936
- setFirstPlay(false);
68937
- }
68938
- };
68939
- const handlePlaying = () => {
68940
- setIsCounting(true);
68941
- setIsPaused(false);
68942
- };
68943
- const handlePause = () => {
68944
- setIsCounting(false);
68945
- setIsPaused(true);
68946
- if (firstPlay) handleChangeSoundVolume(100);
68947
- setFirstPlay(false);
68948
- };
68949
- const handleEnded = () => {
68950
- dispatch(setAdData(void 0));
68951
- };
68952
- const handleError = () => {
68953
- setIsCounting(false);
68954
- };
68955
- const handleLoadedMetadata = () => setDuration(video.duration);
68956
- video.addEventListener("play", handlePlay);
68957
- video.addEventListener("playing", handlePlaying);
68958
- video.addEventListener("pause", handlePause);
68959
- video.addEventListener("ended", handleEnded);
68960
- video.addEventListener("error", handleError);
68961
- video.addEventListener("waiting", () => setIsCounting(false));
68962
- video.addEventListener("loadedmetadata", handleLoadedMetadata);
68963
- video.addEventListener("progress", handleProgress);
68964
- video.addEventListener("timeupdate", handleTimeUpdate);
68965
- (async () => {
68966
- if (!conditions(ConditionName.hasAd)) await handleFullScreen();
68967
- await handleLockOrientation();
68968
- const playPromise = video.play();
68969
- dispatch(setPlay(true));
68970
- if (playPromise !== void 0) playPromise.then(() => {
68971
- handleChangeSoundVolume(100);
68972
- dispatch(setFirstMute(false));
68973
- }).catch(() => {
68974
- handleChangeSoundVolume(0);
68975
- dispatch(setFirstMute(true));
68976
- });
68977
- })();
68978
- return () => {
68979
- video.removeEventListener("play", handlePlay);
68980
- video.removeEventListener("playing", handlePlaying);
68981
- video.removeEventListener("pause", handlePause);
68982
- video.removeEventListener("ended", handleEnded);
68983
- video.removeEventListener("error", handleError);
68984
- video.removeEventListener("waiting", () => setIsCounting(false));
68985
- video.removeEventListener("loadedmetadata", handleLoadedMetadata);
68986
- video.removeEventListener("progress", handleProgress);
68987
- video.removeEventListener("timeupdate", handleTimeUpdate);
68988
- dispatch(setPlay(false));
68989
- };
68990
- }, [ad?.url]);
68991
- const handleTimeUpdate = () => {
68992
- const video = videoTag();
68993
- if (video?.duration) {
68994
- setProgress(video.currentTime / video.duration * 100);
68995
- setCurrentTime(video.currentTime);
68996
- }
68997
- };
68998
- const handleProgress = () => {
68999
- const video = videoTag();
69000
- if (video?.duration && video.buffered.length > 0) setBuffered(video.buffered.end(video.buffered.length - 1) / video.duration * 100);
69001
- };
69002
- return {
69003
- progress,
69004
- buffered,
69005
- currentTime,
69006
- duration,
69007
- firstPlay,
69008
- setFirstPlay,
69009
- isPaused,
69010
- skipCounter,
69011
- hasSkip
69012
- };
69013
- };
69014
- //#endregion
69015
- //#region src/videoPlayerLibrary/shared/ui/src/components/advertisement/MoreInfoButton.tsx
69016
- var MoreInfoButton = ({ link }) => link ? /* @__PURE__ */ jsx("a", {
69017
- href: link,
69018
- target: "_blank",
69019
- className: `pl-absolute pl-z-[3] pl-flex pl-cursor-pointer pl-items-center pl-gap-2 pl-rounded-lg pl-bg-gray-500 pl-font-medium pl-text-gray-100 ${conditions(ConditionName.isTouchScreen) ? "pl-bottom-[56px] pl-left-2 pl-px-[10px] pl-py-[6px] pl-text-xs lg:pl-bottom-[78px] lg:pl-h-11 lg:pl-text-[14px]" : "pl-bottom-[66px] pl-left-6 pl-h-12 pl-px-5 pl-py-2 pl-text-[16px] lg:pl-bottom-[88px]"}`,
69020
- children: "اطلاعات بیشتر"
69021
- }) : null;
69022
- //#endregion
69023
- //#region src/videoPlayerLibrary/shared/ui/src/components/advertisement/SkipButton.tsx
69024
- var SkipButton = ({ skipCounter }) => {
69025
- const { adData } = useAppSelector(({ videoData: { adData } }) => ({ adData }), shallowEqual);
69026
- const dispatch = useAppDispatch();
69027
- return /* @__PURE__ */ jsxs("button", {
69028
- onClick: (event) => {
69029
- event.stopPropagation();
69030
- event.preventDefault();
69031
- dispatch(setAdData(void 0));
69032
- },
69033
- disabled: !!skipCounter && skipCounter > 0,
69034
- className: `pl-absolute pl-z-[3] pl-flex pl-size-max pl-items-center pl-rounded-lg pl-bg-gray-500 pl-p-0.5 pl-pl-4 ${conditions(ConditionName.isTouchScreen) ? "pl-bottom-[56px] pl-right-2 lg:pl-bottom-[78px]" : "pl-bottom-[66px] pl-right-6 lg:pl-bottom-[88px]"}`,
69035
- children: [adData?.banner && /* @__PURE__ */ jsx("img", {
69036
- src: adData.banner,
69037
- height: conditions(ConditionName.isTouchScreen) ? 40 : 44,
69038
- alt: "video-banner",
69039
- className: `pl-w-auto pl-rounded-md ${conditions(ConditionName.isTouchScreen) ? "pl-h-7 lg:pl-h-10" : "pl-h-7 lg:pl-h-11"}`
69040
- }), /* @__PURE__ */ jsx("span", {
69041
- className: `pl-mr-3 pl-font-bold pl-text-gray-100 ${conditions(ConditionName.isTouchScreen) ? "pl-text-xs lg:pl-text-[14px]" : "pl-text-[16px]"}`,
69042
- children: skipCounter && skipCounter > 0 ? `${skipCounter} ثانیه` : "رد کردن"
69043
- })]
69044
- });
69045
- };
69046
- //#endregion
69047
- //#region src/videoPlayerLibrary/shared/ui/src/components/advertisement/UnMuteVideo.tsx
69048
- var UnMuteVideo = ({ advertisement }) => /* @__PURE__ */ jsxs("div", {
69049
- className: `pl-flex pl-cursor-pointer pl-items-center pl-rounded-lg pl-bg-gray-500 ${!advertisement ? "pl-absolute -pl-left-2 pl-top-[60px]" : ""} ${conditions(ConditionName.isTouchScreen) ? "pl-gap-1 pl-px-2 pl-py-[10px]" : "!pl-left-8 pl-gap-2 pl-p-3"} ${conditions(ConditionName.isTouchScreen) && "pl-mx-4"}`,
69050
- children: [/* @__PURE__ */ jsx("img", {
69051
- src: IMAGES.mute,
69052
- alt: "mute icon",
69053
- className: `pl-shrink-0 ${conditions(ConditionName.isTouchScreen) ? "pl-size-4" : "pl-size-6"}`
69054
- }), /* @__PURE__ */ jsx("p", {
69055
- className: `pl-text-[14px] ${!advertisement ? "pl-whitespace-nowrap" : ""} pl-font-medium dark:pl-text-secondary-100`,
69056
- children: "برای پخش صدا روی ویدیو ضربه بزنید."
69057
- })]
69058
- });
69059
- //#endregion
69060
- //#region src/videoPlayerLibrary/shared/ui/src/components/advertisement/ProgressBar.tsx
69061
- var ProgressBar = ({ progress, buffered }) => /* @__PURE__ */ jsxs("div", {
69062
- className: "pl-relative pl-h-1 pl-w-full pl-rounded-[4px] pl-bg-z-secondary-100/[0.4]",
69063
- children: [/* @__PURE__ */ jsx("div", {
69064
- className: "pl-absolute pl-left-0 pl-top-0 pl-h-full pl-rounded-[4px] pl-bg-z-secondary-50/[0.4]",
69065
- style: { width: `${buffered}%` }
69066
- }), /* @__PURE__ */ jsx("div", {
69067
- className: "pl-absolute pl-left-0 pl-top-0 pl-h-full pl-rounded-[4px] pl-bg-primary-500 pl-transition-all pl-duration-150 pl-ease-linear",
69068
- style: { width: `${progress}%` }
69069
- })]
69070
- });
69071
- //#endregion
69072
- //#region src/videoPlayerLibrary/shared/ui/src/components/advertisement/VideoControls.tsx
69073
- var formatTime = (time) => {
69074
- return `${Math.floor(time / 60).toString().padStart(2, "0")}:${Math.floor(time % 60).toString().padStart(2, "0")}`;
69075
- };
69076
- var VideoControls = ({ progress, buffered, duration, currentTime, showControls }) => /* @__PURE__ */ jsxs("div", {
69077
- className: `pl-relative pl-z-[3] pl-flex pl-w-full pl-flex-col pl-transition-opacity pl-duration-500 pl-ease-in-out ${showControls ? "pl-opacity-100" : "pl-pointer-events-none pl-opacity-0"} ${conditions(ConditionName.isTouchScreen) ? "pl-gap-2 pl-px-2" : "pl-gap-4 pl-px-5"}`,
69078
- children: [/* @__PURE__ */ jsx(ProgressBar, {
69079
- progress,
69080
- buffered
69081
- }), /* @__PURE__ */ jsxs("div", {
69082
- className: `pl-flex pl-items-center pl-justify-between pl-px-1`,
69083
- children: [/* @__PURE__ */ jsx(FullScreen, {}), /* @__PURE__ */ jsxs("div", {
69084
- className: "pl-flex pl-items-center pl-gap-4",
69085
- children: [/* @__PURE__ */ jsxs("div", {
69086
- className: `pl-flex pl-items-center pl-gap-1 ${conditions(ConditionName.isTouchScreen) ? "pl-text-[14px]" : "pl-text-[16px]"} pl-font-medium`,
69087
- children: [
69088
- /* @__PURE__ */ jsx("span", {
69089
- className: "pl-text-secondary",
69090
- children: formatTime(duration)
69091
- }),
69092
- /* @__PURE__ */ jsx("span", {
69093
- className: "pl-text-secondary",
69094
- children: "/"
69095
- }),
69096
- /* @__PURE__ */ jsx("span", {
69097
- className: "pl-text-gray-100",
69098
- children: formatTime(currentTime)
69099
- })
69100
- ]
69101
- }), /* @__PURE__ */ jsx(SoundVolume, {})]
69102
- })]
69103
- })]
69104
- });
69105
- //#endregion
69106
- //#region src/videoPlayerLibrary/shared/ui/src/components/advertisement/Advertisement.tsx
69107
- var Advertisement = () => {
69108
- const { params, firstMute, adData } = useAppSelector(({ videoData: { params, adData }, controller: { firstMute } }) => ({
69109
- params,
69110
- firstMute,
69111
- adData
69112
- }), shallowEqual);
69113
- const dispatch = useAppDispatch();
69114
- const { progress, buffered, currentTime, duration, isPaused, skipCounter, hasSkip } = useVideoControls(adData, params);
69115
- const containerRef = useRef(null);
69116
- const { showControls, resetTimer } = useControlsVisibility(isPaused);
69117
- useEffect(() => {
69118
- const container = containerRef.current;
69119
- if (!container) return;
69120
- const handleInteraction = () => resetTimer();
69121
- container.addEventListener("mousemove", handleInteraction);
69122
- container.addEventListener("touchstart", handleInteraction);
69123
- resetTimer();
69124
- return () => {
69125
- container.removeEventListener("mousemove", handleInteraction);
69126
- container.removeEventListener("touchstart", handleInteraction);
69127
- };
69128
- }, [resetTimer]);
69129
- const handleClick = () => {
69130
- if (firstMute) {
69131
- handleChangeSoundVolume(50);
69132
- dispatch(setFirstMute(false));
69133
- }
69134
- if (!conditions(ConditionName.isTouchScreen)) return;
69135
- resetTimer();
69136
- };
69137
- return /* @__PURE__ */ jsxs("div", {
69138
- ref: containerRef,
69139
- onClick: handleClick,
69140
- onDoubleClick: async () => {
69141
- await handleFullScreen();
69142
- await handleLockOrientation();
69143
- },
69144
- className: `pl-flex pl-h-full pl-w-full pl-flex-col pl-justify-end pl-bg-dark-1 ${conditions(ConditionName.isFullScreen) && "!pl-fixed !pl-right-0 !pl-top-0 !pl-h-screen !pl-w-screen"}`,
69145
- style: { zIndex: 1e5 },
69146
- children: [
69147
- /* @__PURE__ */ jsx("video", {
69148
- id: "player-tag",
69149
- src: adData?.url + `?uuid=${getUUID()}`,
69150
- autoPlay: true,
69151
- playsInline: true,
69152
- className: "pl-absolute pl-top-0 pl-size-full"
69153
- }),
69154
- /* @__PURE__ */ jsxs("div", {
69155
- className: `pl-relative pl-flex pl-h-full pl-w-full pl-flex-col pl-justify-between ${conditions(ConditionName.isTouchScreen) ? "pl-pb-3 pl-pt-4 lg:pl-pb-4" : "pl-pb-5 pl-pt-[30px]"}`,
69156
- children: [
69157
- /* @__PURE__ */ jsx("div", {
69158
- className: `pl-relative pl-z-[4] pl-flex pl-items-center pl-gap-5 pl-self-end pl-px-3 ${conditions(ConditionName.isTouchScreenPortrait) && "!pl-h-max !pl-flex-col-reverse !pl-items-start !pl-gap-0 !pl-self-start"} ${conditions(ConditionName.isTouchScreenLandscape) && "!pl-flex-row-reverse !pl-justify-between !pl-self-stretch"}`,
69159
- children: firstMute && /* @__PURE__ */ jsx(UnMuteVideo, { advertisement: true })
69160
- }),
69161
- /* @__PURE__ */ jsx("div", {
69162
- className: `pl-absolute pl-inset-0 pl-z-[2] pl-flex pl-items-center pl-justify-center pl-transition-opacity pl-duration-500 pl-ease-in-out ${showControls ? "pl-opacity-100" : "pl-pointer-events-none pl-opacity-0"}`,
69163
- onClick: () => {
69164
- if (firstMute) {
69165
- handleChangeSoundVolume(50);
69166
- dispatch(setFirstMute(false));
69167
- }
69168
- },
69169
- children: /* @__PURE__ */ jsx(PlayPause, {})
69170
- }),
69171
- /* @__PURE__ */ jsx(VideoControls, {
69172
- buffered,
69173
- currentTime,
69174
- duration,
69175
- progress,
69176
- showControls
69177
- })
69178
- ]
69179
- }),
69180
- /* @__PURE__ */ jsx(MoreInfoButton, {
69181
- link: adData?.ad_link,
69182
- currentTime
69183
- }),
69184
- hasSkip && /* @__PURE__ */ jsx(SkipButton, {
69185
- skipCounter,
69186
- currentTime
69187
- }),
69188
- /* @__PURE__ */ jsx(VideoAreaShadow, {})
69189
- ]
69190
- });
69191
- };
69192
- //#endregion
69193
68892
  //#region src/videoPlayerLibrary/shared/ui/src/components/modules/video-player-library/players/liveAndVodPlayer/videoArea.tsx
69194
68893
  var VideoArea = () => {
69195
68894
  const [isRightDoubleTouched, setIsRightDoubleTouched] = useState(false);
@@ -69265,7 +68964,7 @@ var VideoArea = () => {
69265
68964
  onClick: (event) => conditions(ConditionName.playByClickPoster) && handlePlayPause(event),
69266
68965
  onDoubleClick: (event) => handleDoubleClick(event),
69267
68966
  className: `pl-flex pl-aspect-video pl-h-full pl-max-h-screen pl-items-center pl-bg-black !pl-bg-contain !pl-bg-center !pl-bg-no-repeat ${conditions(ConditionName.isFullScreen) && "dvh !pl-fixed !pl-w-screen"} ${conditions(ConditionName.showMiniPlayer) ? "!pl-fixed !pl-bottom-[10px] !pl-right-[10px] !pl-h-[225px] !pl-w-[400px]" : "pl-relative !pl-w-full"} ${!conditions(ConditionName.isComplexPortrait) && "pl-overflow-hidden"} ${!conditions(ConditionName.isActiveElements) && "pl-cursor-none"}`,
69268
- children: hasAd && !!adData ? /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(Advertisement, {}) }) : /* @__PURE__ */ jsxs(Fragment, { children: [
68967
+ children: hasAd && !!adData ? /* @__PURE__ */ jsx(Suspense, {}) : /* @__PURE__ */ jsxs(Fragment, { children: [
69269
68968
  conditions(ConditionName.showBanner) && /* @__PURE__ */ jsx("div", {
69270
68969
  className: "pl-absolute pl-flex pl-h-full pl-w-full pl-justify-center",
69271
68970
  children: /* @__PURE__ */ jsx("img", {