Files
v10/dist/dev/player/create-player.d.ts

47 lines
1.8 KiB
TypeScript

import { Container } from "./container.js";
import { AnyPlayerFeature, AudioFeatures, AudioPlayerStore, PlayerStore, VideoFeatures, VideoPlayerStore } from "@videojs/core/dom";
import { Media } from "@videojs/media/dom";
import { InferStoreState } from "@videojs/store";
import { FC, ReactNode } from "react";
//#region src/player/create-player.d.ts
interface CreatePlayerConfig<Features extends AnyPlayerFeature[]> {
features: Features;
displayName?: string;
}
interface ProviderProps {
children: ReactNode;
}
interface CreatePlayerResult<Store extends PlayerStore> {
Provider: FC<ProviderProps>;
Container: typeof Container;
usePlayer: UsePlayerHook<Store>;
useMedia: () => Media | null;
}
type UsePlayerHook<Store extends PlayerStore> = {
(): Store;
<R>(selector: (state: InferStoreState<Store>) => R): R;
};
/**
* Create a player instance with typed store, Provider component, Container, and hooks.
*
* @label Video
* @param config - Player configuration with features and optional display name.
*/
declare function createPlayer(config: CreatePlayerConfig<VideoFeatures>): CreatePlayerResult<VideoPlayerStore>;
/**
* Create a player for audio media.
*
* @label Audio
* @param config - Player configuration with features and optional display name.
*/
declare function createPlayer(config: CreatePlayerConfig<AudioFeatures>): CreatePlayerResult<AudioPlayerStore>;
/**
* Create a player with custom features.
*
* @label Generic
* @param config - Player configuration with features and optional display name.
*/
declare function createPlayer<const Features extends AnyPlayerFeature[]>(config: CreatePlayerConfig<Features>): CreatePlayerResult<PlayerStore<Features>>;
//#endregion
export { CreatePlayerConfig, CreatePlayerResult, ProviderProps, UsePlayerHook, createPlayer };
//# sourceMappingURL=create-player.d.ts.map