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