@zezosoft/react-player 0.0.7 → 0.0.9

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.
Files changed (43) hide show
  1. package/dist/VideoPlayer/MediaControls/BottomControls.d.ts +5 -0
  2. package/dist/VideoPlayer/MediaControls/ControlsHeader.d.ts +5 -0
  3. package/dist/VideoPlayer/MediaControls/MiddleControls.d.ts +3 -0
  4. package/dist/VideoPlayer/MediaControls/VideoPlayerControls.d.ts +4 -0
  5. package/dist/VideoPlayer/VideoPlayer.d.ts +1 -0
  6. package/dist/VideoPlayer/components/AdOverlay.d.ts +10 -0
  7. package/dist/VideoPlayer/components/Overlay.d.ts +4 -0
  8. package/dist/VideoPlayer/components/SubtitleOverlay.d.ts +7 -0
  9. package/dist/VideoPlayer/components/controls/BottomControls.d.ts +5 -0
  10. package/dist/VideoPlayer/components/controls/ControlsHeader.d.ts +5 -0
  11. package/dist/VideoPlayer/components/controls/MiddleControls.d.ts +3 -0
  12. package/dist/VideoPlayer/components/controls/VideoPlayerControls.d.ts +4 -0
  13. package/dist/VideoPlayer/components/controls/index.d.ts +4 -0
  14. package/dist/VideoPlayer/components/time-line/TimeLine.d.ts +21 -0
  15. package/dist/VideoPlayer/components/time-line/components/HoverTimeWithPreview.d.ts +16 -0
  16. package/dist/VideoPlayer/components/time-line/components/Thumb.d.ts +9 -0
  17. package/dist/VideoPlayer/components/time-line/components/TimeCodeItem.d.ts +21 -0
  18. package/dist/VideoPlayer/components/time-line/components/TimeCodes.d.ts +15 -0
  19. package/dist/VideoPlayer/components/time-line/utils/getEndTimeByIndex.d.ts +2 -0
  20. package/dist/VideoPlayer/components/time-line/utils/getHoverTimePosition.d.ts +3 -0
  21. package/dist/VideoPlayer/components/time-line/utils/getPositionPercent.d.ts +1 -0
  22. package/dist/VideoPlayer/components/time-line/utils/getTimeScale.d.ts +1 -0
  23. package/dist/VideoPlayer/components/time-line/utils/isInRange.d.ts +1 -0
  24. package/dist/VideoPlayer/components/time-line/utils/positionToMs.d.ts +1 -0
  25. package/dist/VideoPlayer/components/time-line/utils/secondsToTime.d.ts +6 -0
  26. package/dist/VideoPlayer/components/time-line/utils/timeToTimeString.d.ts +1 -0
  27. package/dist/VideoPlayer/constants.d.ts +3 -0
  28. package/dist/VideoPlayer/hooks/index.d.ts +2 -0
  29. package/dist/VideoPlayer/hooks/useAdManager.d.ts +8 -0
  30. package/dist/VideoPlayer/hooks/usePrimaryVideoLifecycle.d.ts +17 -0
  31. package/dist/VideoPlayer/hooks/useVideoEvents.d.ts +1 -1
  32. package/dist/VideoPlayer/hooks/useVideoSource.d.ts +1 -1
  33. package/dist/VideoPlayer/types/AdTypes.d.ts +36 -0
  34. package/dist/VideoPlayer/types/VideoPlayerTypes.d.ts +8 -2
  35. package/dist/VideoPlayer/utils/index.d.ts +1 -0
  36. package/dist/VideoPlayer/utils/qualityManager.d.ts +52 -0
  37. package/dist/components/ui/FullScreenToggle.d.ts +1 -1
  38. package/dist/components/ui/PiPictureInPictureToggle.d.ts +1 -1
  39. package/dist/index.js +1836 -228
  40. package/dist/store/slices/adsSlice.d.ts +24 -0
  41. package/dist/store/slices/index.d.ts +1 -0
  42. package/dist/store/types/StoreTypes.d.ts +44 -5
  43. package/package.json +2 -1
@@ -0,0 +1,5 @@
1
+ import React from "react";
2
+ import "../_components/TimeLine/time-line.css";
3
+ import { IControlsBottomProps } from "../../types";
4
+ declare const BottomControls: React.FC<IControlsBottomProps>;
5
+ export default BottomControls;
@@ -0,0 +1,5 @@
1
+ import * as React from "react";
2
+ import { IControlsHeaderProps } from "../../types";
3
+ import "../_components/styles/video-controls.css";
4
+ declare const ControlsHeader: React.FC<IControlsHeaderProps>;
5
+ export default ControlsHeader;
@@ -0,0 +1,3 @@
1
+ import React from "react";
2
+ declare const MiddleControls: React.FC;
3
+ export default MiddleControls;
@@ -0,0 +1,4 @@
1
+ import * as React from "react";
2
+ import { IPlayerConfig } from "../../types";
3
+ declare const VideoPlayerControls: React.FC<IPlayerConfig>;
4
+ export default VideoPlayerControls;
@@ -2,5 +2,6 @@ import React from "react";
2
2
  import { VideoPlayerProps } from "./types/VideoPlayerTypes";
3
3
  import "../index.css";
4
4
  import "./styles/subtitles.css";
5
+ import "./styles/ads.css";
5
6
  declare const VideoPlayer: React.FC<VideoPlayerProps>;
6
7
  export default VideoPlayer;
@@ -0,0 +1,10 @@
1
+ import React from "react";
2
+ import { AdBreak } from "../types/AdTypes";
3
+ import { IPlayerConfig } from "../../types";
4
+ interface AdOverlayProps {
5
+ adBreak: AdBreak;
6
+ onSkip?: () => void;
7
+ config?: IPlayerConfig;
8
+ }
9
+ declare const AdOverlay: React.FC<AdOverlayProps>;
10
+ export default AdOverlay;
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ import { IPlayerConfig } from "../../types";
3
+ declare const Overlay: React.FC<IPlayerConfig>;
4
+ export default Overlay;
@@ -0,0 +1,7 @@
1
+ import React from "react";
2
+ import { SubtitleStyleConfig } from "../hooks/useSubtitleStyling";
3
+ interface SubtitleOverlayProps {
4
+ styleConfig?: SubtitleStyleConfig;
5
+ }
6
+ declare const SubtitleOverlay: React.FC<SubtitleOverlayProps>;
7
+ export default SubtitleOverlay;
@@ -0,0 +1,5 @@
1
+ import React from "react";
2
+ import "../time-line/time-line.css";
3
+ import { IControlsBottomProps } from "../../../types";
4
+ declare const BottomControls: React.FC<IControlsBottomProps>;
5
+ export default BottomControls;
@@ -0,0 +1,5 @@
1
+ import * as React from "react";
2
+ import { IControlsHeaderProps } from "../../../types";
3
+ import "../styles/video-controls.css";
4
+ declare const ControlsHeader: React.FC<IControlsHeaderProps>;
5
+ export default ControlsHeader;
@@ -0,0 +1,3 @@
1
+ import React from "react";
2
+ declare const MiddleControls: React.FC;
3
+ export default MiddleControls;
@@ -0,0 +1,4 @@
1
+ import * as React from "react";
2
+ import { IPlayerConfig } from "../../../types";
3
+ declare const VideoPlayerControls: React.FC<IPlayerConfig>;
4
+ export default VideoPlayerControls;
@@ -0,0 +1,4 @@
1
+ export { default as BottomControls } from "./BottomControls";
2
+ export { default as ControlsHeader } from "./ControlsHeader";
3
+ export { default as MiddleControls } from "./MiddleControls";
4
+ export { default as VideoPlayerControls } from "./VideoPlayerControls";
@@ -0,0 +1,21 @@
1
+ import React from "react";
2
+ import "./time-line.css";
3
+ export interface TimeCode {
4
+ fromMs: number;
5
+ description: string;
6
+ }
7
+ export interface TimeLineProps {
8
+ max: number;
9
+ currentTime: number;
10
+ bufferTime?: number;
11
+ offset?: number;
12
+ timeCodes?: TimeCode[];
13
+ hideThumbTooltip?: boolean;
14
+ limitTimeTooltipBySides?: boolean;
15
+ secondsPrefix?: string;
16
+ minutesPrefix?: string;
17
+ onChange: (time: number, offsetTime: number) => void;
18
+ getPreviewScreenUrl?: (hoverTimeValue: number) => string;
19
+ trackColor?: string;
20
+ }
21
+ export declare const VideoSeekSlider: React.FC<TimeLineProps>;
@@ -0,0 +1,16 @@
1
+ import React from "react";
2
+ interface HoverTimeWithPreviewProps {
3
+ max: number;
4
+ hoverTimeValue: number;
5
+ trackWidth: number;
6
+ seekHoverPosition: number;
7
+ offset: number;
8
+ isThumbActive: boolean;
9
+ limitTimeTooltipBySides: boolean;
10
+ label: string;
11
+ secondsPrefix?: string;
12
+ minutesPrefix?: string;
13
+ getPreviewScreenUrl?: (hoverTimeValue: number) => string;
14
+ }
15
+ export declare const HoverTimeWithPreview: React.FC<HoverTimeWithPreviewProps>;
16
+ export {};
@@ -0,0 +1,9 @@
1
+ import React from "react";
2
+ interface ThumbProps {
3
+ max: number;
4
+ currentTime: number;
5
+ isThumbActive: boolean;
6
+ trackColor?: string;
7
+ }
8
+ export declare const Thumb: React.FC<ThumbProps>;
9
+ export {};
@@ -0,0 +1,21 @@
1
+ import React from "react";
2
+ export interface TimeCode {
3
+ fromMs: number;
4
+ description: string;
5
+ }
6
+ export interface TimeCodeItemProps {
7
+ currentTime: number;
8
+ seekHoverTime: number;
9
+ bufferTime: number;
10
+ startTime: number;
11
+ endTime: number;
12
+ maxTime: number;
13
+ label?: string;
14
+ isTimePassed?: boolean;
15
+ isBufferPassed?: boolean;
16
+ isHoverPassed?: boolean;
17
+ onHover?: (label: string) => void;
18
+ withGap?: boolean;
19
+ trackColor?: string;
20
+ }
21
+ export declare const TimeCodeItem: React.FC<TimeCodeItemProps>;
@@ -0,0 +1,15 @@
1
+ import React from "react";
2
+ import { TimeCode } from "./TimeCodeItem";
3
+ export interface TimeCodesProps {
4
+ max: number;
5
+ currentTime: number;
6
+ bufferTime: number;
7
+ seekHoverPosition: number;
8
+ timeCodes: TimeCode[] | undefined;
9
+ trackWidth: number;
10
+ mobileSeeking: boolean;
11
+ label: string;
12
+ setLabel: React.Dispatch<React.SetStateAction<string>>;
13
+ trackColor?: string;
14
+ }
15
+ export declare const TimeCodes: React.FC<TimeCodesProps>;
@@ -0,0 +1,2 @@
1
+ import { TimeCode } from "../components/TimeCodeItem";
2
+ export declare const getEndTimeByIndex: (timeCodes: TimeCode[], index: number, max: number) => number;
@@ -0,0 +1,3 @@
1
+ export declare function getHoverTimePosition(seekHoverPosition: number, hoverTimeElement: HTMLDivElement | null, trackWidth: number, limitTimeTooltipBySides: boolean): {
2
+ transform: string;
3
+ };
@@ -0,0 +1 @@
1
+ export declare function getPositionPercent(max: number, current: number): number;
@@ -0,0 +1 @@
1
+ export declare function getTimeScale(currentTime: number, startTime: number, endTime: number, isTimePassed: boolean): number;
@@ -0,0 +1 @@
1
+ export declare const isInRange: (time: number, start: number, end: number) => boolean;
@@ -0,0 +1 @@
1
+ export declare function positionToMs(max: number, position: number, trackWidth: number): number;
@@ -0,0 +1,6 @@
1
+ export interface Time {
2
+ hh: string;
3
+ mm: string;
4
+ ss: string;
5
+ }
6
+ export declare function millisecondsToTime(ms: number, offset?: number): Time;
@@ -0,0 +1 @@
1
+ export declare function timeToTimeString(max: number, seekHoverTime: number, offset?: number, minutesPrefix?: string, secondsPrefix?: string): string;
@@ -0,0 +1,3 @@
1
+ export declare const CONTROL_INTERACTION_EVENT = "video-controls:interaction";
2
+ export declare const CONTROLS_HIDE_DELAY_MS = 3000;
3
+ export declare const SKIP_INTERVAL_SECONDS = 10;
@@ -5,3 +5,5 @@ export { useVideoTracking } from "./useVideoTracking";
5
5
  export { useIntroSkip } from "./useIntroSkip";
6
6
  export { useEpisodes } from "./useEpisodes";
7
7
  export { useVideoEvents } from "./useVideoEvents";
8
+ export { useAdManager } from "./useAdManager";
9
+ export { usePrimaryVideoLifecycle } from "./usePrimaryVideoLifecycle";
@@ -0,0 +1,8 @@
1
+ import { AdConfig, AdBreak, AdType } from "../types/AdTypes";
2
+ export declare const useAdManager: (adConfig?: AdConfig) => {
3
+ isAdPlaying: boolean;
4
+ currentAd: AdBreak | null;
5
+ adType: AdType | null;
6
+ skipAd: () => void;
7
+ endAd: () => void;
8
+ };
@@ -0,0 +1,17 @@
1
+ import { VideoState } from "../../store/types/StoreTypes";
2
+ interface UsePrimaryVideoLifecycleParams {
3
+ hasPreRoll: boolean;
4
+ trackSrc: string;
5
+ }
6
+ interface PrimaryVideoLifecycleResult {
7
+ registerVideoRef: (node: HTMLVideoElement | null) => void;
8
+ videoRef: HTMLVideoElement | null;
9
+ isAdPlaying: boolean;
10
+ currentAd: VideoState["currentAd"];
11
+ adType: VideoState["adType"];
12
+ initialAdFinished: boolean;
13
+ shouldCoverMainVideo: boolean;
14
+ shouldShowPlaceholder: boolean;
15
+ }
16
+ export declare const usePrimaryVideoLifecycle: ({ hasPreRoll, trackSrc, }: UsePrimaryVideoLifecycleParams) => PrimaryVideoLifecycleResult;
17
+ export {};
@@ -6,5 +6,5 @@ export declare const useVideoEvents: () => {
6
6
  onProgress: (e: React.SyntheticEvent<HTMLVideoElement>) => void;
7
7
  onPlay: () => void;
8
8
  onPause: () => void;
9
- onEnded: () => void;
9
+ onEnded: (e: unknown) => void;
10
10
  };
@@ -1 +1 @@
1
- export declare const useVideoSource: (trackSrc: string, type?: "hls" | "mp4" | "other" | "youtube" | undefined) => void;
1
+ export declare const useVideoSource: (trackSrc: string, type?: "hls" | "dash" | "mp4" | "other" | "youtube" | undefined) => void;
@@ -0,0 +1,36 @@
1
+ export type AdType = "pre-roll" | "mid-roll" | "post-roll" | "overlay";
2
+ export interface AdBreak {
3
+ id: string;
4
+ type: AdType;
5
+ time: number;
6
+ adUrl: string;
7
+ skipable?: boolean;
8
+ skipAfter?: number;
9
+ duration?: number;
10
+ sponsoredUrl?: string;
11
+ title?: string;
12
+ description?: string;
13
+ relevance?: "high" | "medium" | "low";
14
+ }
15
+ export interface AdConfig {
16
+ preRoll?: AdBreak;
17
+ midRoll?: AdBreak[];
18
+ postRoll?: AdBreak;
19
+ overlay?: {
20
+ imageUrl: string;
21
+ clickUrl?: string;
22
+ showDuration: number;
23
+ position?: "top-left" | "top-right" | "bottom-left" | "bottom-right";
24
+ };
25
+ smartPlacement?: {
26
+ enabled: boolean;
27
+ minVideoDuration?: number;
28
+ minGapBetweenAds?: number;
29
+ avoidNearEnd?: number;
30
+ preferNaturalBreaks?: boolean;
31
+ };
32
+ onAdStart?: (adBreak: AdBreak) => void;
33
+ onAdEnd?: (adBreak: AdBreak) => void;
34
+ onAdSkip?: (adBreak: AdBreak) => void;
35
+ onAdError?: (adBreak: AdBreak, error: Error) => void;
36
+ }
@@ -1,13 +1,18 @@
1
- import { TimeCode } from "../_components/TimeLine/TimeLine";
1
+ import { TimeCode } from "../components/time-line/TimeLine";
2
2
  import { IOnWatchTimeUpdated } from "../../types";
3
3
  import { SubtitleStyleConfig } from "../hooks/useSubtitleStyling";
4
+ import { AdConfig } from "./AdTypes";
4
5
  export interface VideoPlayerProps {
5
6
  trackSrc: string;
7
+ showControls?: boolean;
8
+ isMute?: boolean;
9
+ onEnded?: (e: React.SyntheticEvent<HTMLVideoElement>) => void;
10
+ onError?: (e?: React.SyntheticEvent<HTMLVideoElement, Event>) => void;
6
11
  trackTitle?: string;
7
12
  trackPoster?: string;
8
13
  isTrailer?: boolean;
9
14
  className?: string;
10
- type?: "hls" | "mp4" | "other" | "youtube" | undefined;
15
+ type?: "hls" | "dash" | "mp4" | "other" | "youtube" | undefined;
11
16
  width?: string;
12
17
  height?: string;
13
18
  onClose?: () => void;
@@ -37,6 +42,7 @@ export interface VideoPlayerProps {
37
42
  showAtEnd?: boolean;
38
43
  };
39
44
  subtitleStyle?: SubtitleStyleConfig;
45
+ ads?: AdConfig;
40
46
  }
41
47
  export type { SubtitleTrack, Episode } from "../../store/types/StoreTypes";
42
48
  export interface IntroConfig {
@@ -27,3 +27,4 @@ export declare const millisecondsToSeconds: (milliseconds: number) => number;
27
27
  * @returns
28
28
  */
29
29
  export declare const getExtensionFromUrl: (url: string) => string | undefined;
30
+ export { QualityManager } from "./qualityManager";
@@ -0,0 +1,52 @@
1
+ import Hls from "hls.js";
2
+ import * as dashjs from "dashjs";
3
+ import { StreamType } from "../../store/types/StoreTypes";
4
+ export declare class QualityManager {
5
+ /**
6
+ * Set video quality for HLS streams with OTT-grade smoothness
7
+ *
8
+ * Best practices implemented:
9
+ * 1. Use currentLevel for immediate quality change
10
+ * 2. Use autoLevelCapping to prevent ABR from switching back
11
+ * 3. Use nextLevel to ensure next segment uses selected quality
12
+ * 4. Handle edge cases and errors gracefully
13
+ *
14
+ * @param hlsInstance HLS.js instance (null for native HLS, undefined when not available)
15
+ * @param levelIndex Quality level index (-1 for auto)
16
+ */
17
+ static setHlsQuality(hlsInstance: Hls | null | undefined, levelIndex: number): void;
18
+ /**
19
+
20
+ * @param dashInstance DASH.js instance
21
+ * @param qualityId Quality level ID (undefined/null for auto)
22
+ */
23
+ static setDashQuality(dashInstance: dashjs.MediaPlayerClass | undefined | null, qualityIndex: number | null | undefined): void;
24
+ /**
25
+ * @param hlsInstance HLS.js instance
26
+ * @returns Array of quality level objects
27
+ */
28
+ static getHlsQualityLevels(hlsInstance: Hls): Array<{
29
+ height: number;
30
+ bitrate?: number;
31
+ originalIndex: number;
32
+ }>;
33
+ /**
34
+ * @param dashInstance DASH.js instance
35
+ * @returns Array of quality level objects
36
+ */
37
+ static getDashQualityLevels(dashInstance: dashjs.MediaPlayerClass): Array<{
38
+ height: number;
39
+ bitrate?: number;
40
+ id: string;
41
+ }>;
42
+ /**
43
+ * @param streamType Type of stream (hls, dash, etc.)
44
+ * @param qualityIdentifier Quality level identifier (index for HLS, ID for DASH)
45
+ */
46
+ static setQuality(streamType: StreamType, qualityIdentifier: string): void;
47
+ /**
48
+ * @param streamType Type of stream (hls, dash, etc.)
49
+ */
50
+ static setAutoQuality(streamType: StreamType): void;
51
+ }
52
+ export default QualityManager;
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import "../../VideoPlayer/_components/styles/video-controls.css";
2
+ import "../../VideoPlayer/components/styles/video-controls.css";
3
3
  interface FullScreenToggleProps {
4
4
  isFullScreen: boolean;
5
5
  onClick?: () => void;
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import "../../VideoPlayer/_components/styles/video-controls.css";
2
+ import "../../VideoPlayer/components/styles/video-controls.css";
3
3
  interface PiPictureInPictureToggleProps {
4
4
  onClick?: () => void;
5
5
  className?: string;