@devix-technologies/react-gjirafa-vp-player 1.0.0 → 1.0.2
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.
- package/dist/App.d.ts +2 -0
- package/dist/components/Feedback.d.ts +25 -0
- package/dist/components/VPPlayer/index.d.ts +2 -0
- package/dist/components/VPPlayer/ui/index.d.ts +1 -0
- package/dist/components/VPPlayer/ui/styled.d.ts +42 -0
- package/dist/config/index.d.ts +1 -0
- package/dist/config/vpPlayerConfig.d.ts +9 -0
- package/dist/constants/configs.d.ts +22 -0
- package/dist/constants/index.d.ts +1 -0
- package/dist/constants/storybook.d.ts +11 -0
- package/dist/constants/styles.d.ts +11 -0
- package/dist/constants/urls.d.ts +18 -0
- package/dist/constants/vpPlayer.d.ts +29 -0
- package/dist/contexts/VPPlayerContext.d.ts +53 -0
- package/dist/contexts/index.d.ts +1 -0
- package/dist/features/VPPlayer.d.ts +27 -0
- package/dist/features/index.d.ts +1 -0
- package/dist/features/stories/ads/Ads.stories.d.ts +13 -0
- package/dist/features/stories/context/Context.stories.d.ts +10 -0
- package/dist/features/stories/index.d.ts +3 -0
- package/dist/features/stories/playback/Playback.stories.d.ts +15 -0
- package/dist/fixtures/index.d.ts +1 -0
- package/dist/fixtures/playlist.d.ts +11 -0
- package/dist/hooks/index.d.ts +3 -0
- package/dist/hooks/useVPPlayerLogic.d.ts +16 -0
- package/dist/hooks/useVPPlayerScript.d.ts +13 -0
- package/dist/hooks/useVideoData.d.ts +21 -0
- package/dist/index.d.ts +2 -0
- package/dist/interfaces/config.d.ts +303 -0
- package/dist/interfaces/index.d.ts +3 -0
- package/dist/interfaces/instance.d.ts +11 -0
- package/dist/interfaces/props.d.ts +54 -0
- package/dist/main.d.ts +1 -0
- package/dist/react-gjirafa-vp-player.es.js +1840 -0
- package/dist/react-gjirafa-vp-player.umd.js +84 -0
- package/dist/types/api.types.d.ts +50 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/vpPlayerConfigBuilder.d.ts +29 -0
- package/dist/utils/vpPlayerUtils.d.ts +8 -0
- package/package.json +1 -1
- package/dist/assets/index-C9o-nGUf.js +0 -111
- package/dist/assets/index-kINGwdwO.css +0 -1
- package/dist/index.html +0 -13
package/dist/App.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Props for the FeedbackMessage component.
|
|
4
|
+
*/
|
|
5
|
+
interface FeedbackMessageProps {
|
|
6
|
+
type: "error" | "loading" | "success" | "warning";
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
className?: string;
|
|
9
|
+
icon?: ReactNode;
|
|
10
|
+
action?: ReactNode;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* FeedbackMessage component for displaying various types of messages (error, loading, success, warning).
|
|
14
|
+
* Can be customized with an icon, action button, and additional styles.
|
|
15
|
+
*
|
|
16
|
+
* @param {FeedbackMessageProps} props - The properties for the feedback message.
|
|
17
|
+
* @param {"error" | "loading" | "success" | "warning"} props.type - The type of message to display.
|
|
18
|
+
* @param {ReactNode} props.children - The content of the message.
|
|
19
|
+
* @param {string} [props.className] - Custom class for additional styling.
|
|
20
|
+
* @param {ReactNode} [props.icon] - Optional icon to display before the message.
|
|
21
|
+
* @param {ReactNode} [props.action] - Optional action button (e.g., "Retry").
|
|
22
|
+
* @returns {JSX.Element} The rendered feedback message component.
|
|
23
|
+
*/
|
|
24
|
+
export declare const FeedbackMessage: ({ type, children, className, icon, action }: FeedbackMessageProps) => import("react/jsx-runtime").JSX.Element;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./styled";
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Styled component for the video player container.
|
|
3
|
+
*
|
|
4
|
+
* @component
|
|
5
|
+
* @param {string} [width] - The width of the player (default: "100%").
|
|
6
|
+
* @param {string} [height] - The height of the player (default: "100%").
|
|
7
|
+
* @param {string[]} [$hiddenClasses] - CSS class names to hide elements inside the player.
|
|
8
|
+
* @param {string} [className] - CSS class name for additional styling.
|
|
9
|
+
*/
|
|
10
|
+
export declare const PlayerContainer: import("@emotion/styled").StyledComponent<{
|
|
11
|
+
theme?: import("@emotion/react").Theme;
|
|
12
|
+
as?: React.ElementType;
|
|
13
|
+
} & {
|
|
14
|
+
width?: string;
|
|
15
|
+
height?: string;
|
|
16
|
+
$hiddenClasses?: string[];
|
|
17
|
+
className?: string;
|
|
18
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
19
|
+
/**
|
|
20
|
+
* Styled component for the full-screen overlay when the player is active.
|
|
21
|
+
*
|
|
22
|
+
* @component
|
|
23
|
+
* @param {string} [className] - CSS class name for additional styling.
|
|
24
|
+
*/
|
|
25
|
+
export declare const Overlay: import("@emotion/styled").StyledComponent<{
|
|
26
|
+
theme?: import("@emotion/react").Theme;
|
|
27
|
+
as?: React.ElementType;
|
|
28
|
+
} & {
|
|
29
|
+
className?: string;
|
|
30
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
31
|
+
/**
|
|
32
|
+
* Styled wrapper for the player, adjusting its size based on viewport width.
|
|
33
|
+
*
|
|
34
|
+
* @component
|
|
35
|
+
* @param {string} [className] - CSS class name for additional styling.
|
|
36
|
+
*/
|
|
37
|
+
export declare const PlayerWrapper: import("@emotion/styled").StyledComponent<{
|
|
38
|
+
theme?: import("@emotion/react").Theme;
|
|
39
|
+
as?: React.ElementType;
|
|
40
|
+
} & {
|
|
41
|
+
className?: string;
|
|
42
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./vpPlayerConfig";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { VPPlayerConfig } from '@/interfaces';
|
|
2
|
+
/**
|
|
3
|
+
* Default configuration for the VP Player.
|
|
4
|
+
*
|
|
5
|
+
* @constant
|
|
6
|
+
* @type {VPPlayerConfig}
|
|
7
|
+
* @see {@link https://vp.gjirafa.tech/documentation/docs/web-player/setup-the-player/configuration}
|
|
8
|
+
*/
|
|
9
|
+
export declare const defaultVPPlayerConfig: VPPlayerConfig;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { VPPlayerConfig } from "@/interfaces/config";
|
|
2
|
+
/**
|
|
3
|
+
* Base configuration for VP Player with common settings.
|
|
4
|
+
*/
|
|
5
|
+
export declare const baseConfig: Partial<VPPlayerConfig>;
|
|
6
|
+
/**
|
|
7
|
+
* Base configuration with autoplay enabled.
|
|
8
|
+
*/
|
|
9
|
+
export declare const baseConfigWithAutoplay: Partial<VPPlayerConfig>;
|
|
10
|
+
/**
|
|
11
|
+
* Base configuration for ads with common ad settings.
|
|
12
|
+
*/
|
|
13
|
+
export declare const baseConfigWithAds: Partial<VPPlayerConfig>;
|
|
14
|
+
/**
|
|
15
|
+
* Generates an ad configuration for VP Player based on provided parameters.
|
|
16
|
+
* @param breakType - The type of ad break (e.g., "preroll", "postroll", "midroll").
|
|
17
|
+
* @param adTagUrls - Array of ad tag URLs to use for the ad break.
|
|
18
|
+
* @param breakTimingType - The timing type for the ad break (e.g., "time", "percentage", "playlist").
|
|
19
|
+
* @param breakTimingValue - The timing value for the ad break (e.g., 0 for immediate, 2 for playlist index).
|
|
20
|
+
* @returns A partial VPPlayerConfig with the ad configuration.
|
|
21
|
+
*/
|
|
22
|
+
export declare const getAdConfig: (breakType: "preroll" | "postroll" | "midroll", adTagUrls: string[], breakTimingType?: "time" | "percentage" | "playlist", breakTimingValue?: number) => Partial<VPPlayerConfig>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./vpPlayer";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ArgTypes } from "@storybook/react";
|
|
2
|
+
/**
|
|
3
|
+
* Common Storybook argTypes used across stories.
|
|
4
|
+
*/
|
|
5
|
+
export declare const COMMON_ARGTYPES: Partial<ArgTypes<Record<string, unknown>>>;
|
|
6
|
+
/**
|
|
7
|
+
* Default API key and project ID for Storybook.
|
|
8
|
+
*/
|
|
9
|
+
export declare const DEFAULT_API_KEY: any;
|
|
10
|
+
export declare const DEFAULT_PLAYLIST_ID = "lzxikggu";
|
|
11
|
+
export declare const DEFAULT_PROJECT_ID = "agmipnxc";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Common styles for Storybook stories.
|
|
3
|
+
*/
|
|
4
|
+
/** Style for vertical playback containers (e.g., VerticalPlayback, VerticalPlaylistPlayback). */
|
|
5
|
+
export declare const VERTICAL_PLAYBACK_STYLE: React.CSSProperties;
|
|
6
|
+
/** Base style for multiple players containers (e.g., MultiplePlayersSideBySide, MultiplePlayersStacked). */
|
|
7
|
+
export declare const MULTIPLE_PLAYERS_BASE_STYLE: React.CSSProperties;
|
|
8
|
+
/** Style for side-by-side multiple players (e.g., MultiplePlayersSideBySide). */
|
|
9
|
+
export declare const MULTIPLE_PLAYERS_SIDE_BY_SIDE_STYLE: React.CSSProperties;
|
|
10
|
+
/** Style for stacked multiple players (e.g., MultiplePlayersStacked). */
|
|
11
|
+
export declare const MULTIPLE_PLAYERS_STACKED_STYLE: React.CSSProperties;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Constants for video URLs used across the application and Storybook stories.
|
|
3
|
+
*/
|
|
4
|
+
/** URL for the Big Buck Bunny video */
|
|
5
|
+
export declare const BIG_BUCK_BUNNY_URL = "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4";
|
|
6
|
+
/** URL for the Elephants Dream video */
|
|
7
|
+
export declare const ELEPHANTS_DREAM_URL = "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4";
|
|
8
|
+
/** URL for the Pexels vertical video */
|
|
9
|
+
export declare const PEXELS_VERTICAL_VIDEO_URL = "https://videos.pexels.com/video-files/4678261/4678261-hd_1080_1920_25fps.mp4";
|
|
10
|
+
/** URL for the Pexels thumbnail */
|
|
11
|
+
export declare const PEXELS_THUMBNAIL_URL = "https://images.pexels.com/videos/4678261/pexels-photo-4678261.jpeg?auto=compress&cs=tinysrgb&w=600";
|
|
12
|
+
/**
|
|
13
|
+
* Constants for ad tag URLs used in Storybook stories.
|
|
14
|
+
*/
|
|
15
|
+
/** Ad tag URL for linear ads */
|
|
16
|
+
export declare const AD_TAG_LINEAR_URL = "https://pubads.g.doubleclick.net/gampad/ads?sz=640x480&iu=/124319096/external/single_ad_samples&ciu_szs=300x250&impl=s&gdfp_req=1&env=vp&output=vast&unviewed_position_start=1&cust_params=deployment%3Ddevsite%26sample_ct%3Dlinear&correlator=";
|
|
17
|
+
/** Ad tag URL for skippable linear ads */
|
|
18
|
+
export declare const AD_TAG_SKIPPABLE_LINEAR_URL = "https://pubads.g.doubleclick.net/gampad/ads?sz=640x480&iu=/124319096/external/single_ad_samples&ciu_szs=300x250&impl=s&gdfp_req=1&env=vp&output=vast&unviewed_position_start=1&cust_params=deployment%3Ddevsite%26sample_ct%3Dskippablelinear&correlator=";
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates the URL for fetching a single video by projectId and videoId.
|
|
3
|
+
* @param {string} projectId - The project ID.
|
|
4
|
+
* @param {string} videoId - The video ID.
|
|
5
|
+
* @returns {string} - The complete API URL for single video fetch.
|
|
6
|
+
*/
|
|
7
|
+
export declare const getSingleVideoUrl: (projectId: string, videoId: string) => string;
|
|
8
|
+
/**
|
|
9
|
+
* Generates the URL for fetching a playlist by projectId and playlistId.
|
|
10
|
+
* @param {string} projectId - The project ID.
|
|
11
|
+
* @param {string} playlistId - The playlist ID.
|
|
12
|
+
* @returns {string} - The complete API URL for playlist fetch.
|
|
13
|
+
*/
|
|
14
|
+
export declare const getPlaylistUrl: (projectId: string, playlistId: string) => string;
|
|
15
|
+
/**
|
|
16
|
+
* Generates the URL for loading the VP Player script by version.
|
|
17
|
+
* @param {string} playerVersion - The version of the VP Player script (e.g., 'latest', 'v2.1.1').
|
|
18
|
+
* @returns {string} - The complete URL for the player script.
|
|
19
|
+
*/
|
|
20
|
+
export declare const getPlayerScriptUrl: (playerVersion: string) => string;
|
|
21
|
+
/**
|
|
22
|
+
* Generates a full player DOM element ID based on provided playerId and videoId.
|
|
23
|
+
* Falls back to "default" if playerId is not provided.
|
|
24
|
+
*
|
|
25
|
+
* @param playerId - Base identifier for the player.
|
|
26
|
+
* @param videoId - Optional video identifier.
|
|
27
|
+
* @returns Full DOM element ID string.
|
|
28
|
+
*/
|
|
29
|
+
export declare const generatePlayerId: (playerId?: string, videoId?: string) => string;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { VPPlayerProps } from "@/interfaces";
|
|
3
|
+
/**
|
|
4
|
+
* Interface defining the parameters for initializing the VPPlayer.
|
|
5
|
+
*
|
|
6
|
+
* @interface PlayerParams
|
|
7
|
+
*/
|
|
8
|
+
interface PlayerParams {
|
|
9
|
+
playerId?: string;
|
|
10
|
+
videoId?: string;
|
|
11
|
+
projectId?: string;
|
|
12
|
+
videoUrl?: string;
|
|
13
|
+
playlistId?: string;
|
|
14
|
+
scriptUrl?: string;
|
|
15
|
+
version?: string | null;
|
|
16
|
+
config?: VPPlayerProps["config"];
|
|
17
|
+
thumbnailUrl?: string;
|
|
18
|
+
isReels?: boolean;
|
|
19
|
+
hiddenClasses?: string[];
|
|
20
|
+
apiKey?: string;
|
|
21
|
+
className?: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Interface defining the context for VPPlayer.
|
|
25
|
+
*
|
|
26
|
+
* @interface VPPlayerContextType
|
|
27
|
+
*/
|
|
28
|
+
interface VPPlayerContextType {
|
|
29
|
+
showPlayer: (params: PlayerParams) => void;
|
|
30
|
+
hidePlayer: () => void;
|
|
31
|
+
isPlayerVisible: boolean;
|
|
32
|
+
playerParams: PlayerParams | null;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* VPPlayerProvider component provides context for managing the VPPlayer state.
|
|
36
|
+
*
|
|
37
|
+
* @function
|
|
38
|
+
* @param {Object} props - The component props.
|
|
39
|
+
* @param {React.ReactNode} props.children - The child components.
|
|
40
|
+
* @returns {JSX.Element} The provider component for VPPlayer.
|
|
41
|
+
*/
|
|
42
|
+
export declare const VPPlayerProvider: React.FC<{
|
|
43
|
+
children: React.ReactNode;
|
|
44
|
+
}>;
|
|
45
|
+
/**
|
|
46
|
+
* Hook for accessing the VPPlayer context.
|
|
47
|
+
*
|
|
48
|
+
* @function
|
|
49
|
+
* @throws {Error} If used outside of the VPPlayerProvider.
|
|
50
|
+
* @returns {VPPlayerContextType} The VPPlayer context.
|
|
51
|
+
*/
|
|
52
|
+
export declare const useVPPlayer: () => VPPlayerContextType;
|
|
53
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./VPPlayerContext";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { VPPlayerProps } from "@/interfaces";
|
|
2
|
+
/**
|
|
3
|
+
* Video Player Component for rendering a video player with overlay and responsive behavior.
|
|
4
|
+
* Handles initialization of the player and displays loading/error states.
|
|
5
|
+
*
|
|
6
|
+
* @function
|
|
7
|
+
* @param {VPPlayerProps} props - The properties for configuring the video player.
|
|
8
|
+
* @param {string} props.playerId - Unique identifier for the player instance.
|
|
9
|
+
* @param {string} [props.videoId] - ID of the video to be played.
|
|
10
|
+
* @param {string} [props.version] - Version of the player.
|
|
11
|
+
* @param {string} [props.videoUrl] - Direct video URL (bypasses API calls).
|
|
12
|
+
* @param {string} [props.projectId] - Project ID associated with the video.
|
|
13
|
+
* @param {string} [props.playlistId] - Playlist ID if playing a collection of videos.
|
|
14
|
+
* @param {string} [props.scriptUrl] - URL of the video player script.
|
|
15
|
+
* @param {object} [props.config={}] - Configuration settings for the player.
|
|
16
|
+
* @param {string} [props.apiKey] - API key for authentication (if required).
|
|
17
|
+
* @param {boolean} [props.isReels=false] - Determines if the player should behave as a short-video reel.
|
|
18
|
+
* @param {string[]} [props.hiddenClasses=[]] - CSS classes to hide player elements.
|
|
19
|
+
* @param {function} [props.onClose] - Callback triggered when the player is closed.
|
|
20
|
+
* @param {boolean} [props.isPlayerVisible=false] - Controls the initial visibility of the player.
|
|
21
|
+
* @param {string} [props.className] - CSS class name for additional styling.
|
|
22
|
+
* @returns {JSX.Element} The rendered video player component.
|
|
23
|
+
*/
|
|
24
|
+
declare const VPPlayer: ({ playerId, videoId, version, videoUrl, projectId, playlistId, scriptUrl, config, apiKey, isReels, hiddenClasses, onClose, className, }: VPPlayerProps & {
|
|
25
|
+
className?: string;
|
|
26
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
27
|
+
export default VPPlayer;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as VPPlayer } from './VPPlayer';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import { VPPlayer } from "@/components/VPPlayer";
|
|
3
|
+
declare const meta: Meta<typeof VPPlayer>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof VPPlayer>;
|
|
6
|
+
export declare const SingleVideoOnePrerollAd: Story;
|
|
7
|
+
export declare const SingleVideoOnePostrollAd: Story;
|
|
8
|
+
export declare const SingleVideoMultiplePrerollAds: Story;
|
|
9
|
+
export declare const PlaylistOnePrerollEveryAd: Story;
|
|
10
|
+
export declare const PlaylistOneMidrollAd: Story;
|
|
11
|
+
export declare const PlaylistOnePostrollAddEveryVideo: Story;
|
|
12
|
+
export declare const PlaylistMultiplePrerollAdsEveryVideo: Story;
|
|
13
|
+
export declare const PlaylistMultipleMidrollAds: Story;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import { VPPlayer } from "@/components/VPPlayer";
|
|
3
|
+
declare const meta: Meta<typeof VPPlayer>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof VPPlayer>;
|
|
6
|
+
export declare const NoControlsSingleVideo: Story;
|
|
7
|
+
export declare const IsReelsWithContextPlaylistHiddenElements: Story;
|
|
8
|
+
export declare const IsReelsWithContextModalCentered: Story;
|
|
9
|
+
export declare const ContextWrapperModal: Story;
|
|
10
|
+
export declare const ContextCustomizedPortalPlayer: Story;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import { VPPlayer } from "@/components/VPPlayer";
|
|
3
|
+
declare const meta: Meta<typeof VPPlayer>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof VPPlayer>;
|
|
6
|
+
export declare const SingleVideoProvidedFile: Story;
|
|
7
|
+
export declare const SingleVideoAPI: Story;
|
|
8
|
+
export declare const PlaylistProvided: Story;
|
|
9
|
+
export declare const PlaylistAPI: Story;
|
|
10
|
+
export declare const HorizontalPlayback: Story;
|
|
11
|
+
export declare const VerticalPlayback: Story;
|
|
12
|
+
export declare const VerticalPlaylistPlayback: Story;
|
|
13
|
+
export declare const FloatingVideo: Story;
|
|
14
|
+
export declare const MultiplePlayersSideBySide: Story;
|
|
15
|
+
export declare const MultiplePlayersStacked: Story;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./playlist";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { VPPlayerInstance, VPPlayerProps } from "@/interfaces";
|
|
2
|
+
/**
|
|
3
|
+
* Custom hook to manage VP Player logic, including fetching video data,
|
|
4
|
+
* initializing the player, and handling lifecycle events.
|
|
5
|
+
*
|
|
6
|
+
* @function
|
|
7
|
+
* @param {VPPlayerProps} props - The properties required to configure the VP Player.
|
|
8
|
+
* @returns {Object} An object containing player references, script loading status, loading state, and errors.
|
|
9
|
+
*/
|
|
10
|
+
export declare const useVPPlayerLogic: ({ playerId, videoId: propVideoId, version, videoUrl, projectId, playlistId, scriptUrl, config, apiKey, isReels, }: VPPlayerProps) => {
|
|
11
|
+
playerRef: import("react").RefObject<HTMLDivElement | null>;
|
|
12
|
+
playerInstanceRef: import("react").RefObject<VPPlayerInstance | null>;
|
|
13
|
+
isScriptLoaded: boolean;
|
|
14
|
+
isLoading: boolean;
|
|
15
|
+
error: string | null;
|
|
16
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom hook to dynamically load the VP Player script into the document.
|
|
3
|
+
* It ensures that the script is only loaded once and provides a loading state.
|
|
4
|
+
*
|
|
5
|
+
* @function
|
|
6
|
+
* @param {string | null} [version] - The version of the VP Player script to load (defaults to "latest").
|
|
7
|
+
* @param {string} [scriptUrl] - Custom script URL (if provided, it overrides the version-based URL).
|
|
8
|
+
* @returns {{ isLoaded: boolean; error: string | null }} Indicates load success and any error message.
|
|
9
|
+
*/
|
|
10
|
+
export declare const useVPPlayerScript: (version?: string | null, scriptUrl?: string) => {
|
|
11
|
+
isLoaded: boolean;
|
|
12
|
+
error: string | null;
|
|
13
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { VideoDataResult } from "@/types";
|
|
2
|
+
/**
|
|
3
|
+
* Custom hook for fetching video data, including playback URLs and playlists.
|
|
4
|
+
* Supports retry logic, timeout, error handling, and in-memory caching.
|
|
5
|
+
*
|
|
6
|
+
* @function
|
|
7
|
+
* @param {Object} params - The parameters for fetching video data.
|
|
8
|
+
* @param {string} [params.projectId] - The project ID required for API calls.
|
|
9
|
+
* @param {string} [params.videoId] - The video ID to fetch a single video's playback URL.
|
|
10
|
+
* @param {string} [params.playlistId] - The playlist ID to fetch a list of videos.
|
|
11
|
+
* @param {string} [params.videoUrl] - The direct video URL (skips API call if provided).
|
|
12
|
+
* @param {string} [params.apiKey] - The API key for authentication (optional, defaults to environment variable).
|
|
13
|
+
* @returns {VideoDataResult} - Result object with URL, playlist, loading and error states
|
|
14
|
+
*/
|
|
15
|
+
export declare const useVideoData: ({ projectId, videoId, playlistId, videoUrl, apiKey, }: {
|
|
16
|
+
projectId?: string;
|
|
17
|
+
videoId?: string;
|
|
18
|
+
playlistId?: string;
|
|
19
|
+
videoUrl?: string;
|
|
20
|
+
apiKey?: string;
|
|
21
|
+
}) => VideoDataResult;
|
package/dist/index.d.ts
ADDED