@vime/react
Version:
React bindings for the Vime media player.
19 lines (18 loc) • 954 B
TypeScript
import { PlayerProps, WritableProps } from '@vime/core';
/**
* Returns the closest ancestor player to the given `ref`.
*/
export declare const usePlayer: (ref: React.RefObject<HTMLElement | null>) => HTMLVmPlayerElement | null;
export declare type PropBinding<P extends keyof PlayerProps> = [
value: PlayerProps[P],
setValue: P extends keyof WritableProps ? (value: PlayerProps[P]) => void : undefined
];
/**
* Binds the given `prop` to the closest ancestor player of the given `ref`. When the property
* changes on the player, this hook will trigger a re-render with the new value.
*
* @param ref The ref to start searching from.
* @param prop The property to bind to.
* @param defaultValue The initial value of the property until the the player context is bound.
*/
export declare const usePlayerContext: <P extends keyof PlayerProps>(ref: React.RefObject<HTMLElement | null>, prop: P, defaultValue: PlayerProps[P]) => PropBinding<P>;