UNPKG

use-video-interval

Version:

A React hook for executing a callback at customizable intervals during video playback.

35 lines (34 loc) 930 B
import { useVideoFrameProps } from '../types/use-video-frame'; /** * useVideoFrame * * @example * ```tsx * import { useRef, useState } from 'react'; * * function App() { * const videoRef = useRef<HTMLVideoElement>( null ); * const [ showOverlay, setShowOverlay ] = useState( false ); * * useVideoFrame( videoRef, { * 3: () => setShowOverlay( true ), * 8: () => alert( 'This is 8 seconds!' ), * 15: () => console.log( 'Reached 15s mark' ) * }); * * return ( * <> * <video ref={ videoRef } src="" /> * { showOverlay && <Overlay /> } * </> * ); * } * ``` * * @param videoRef - A reference to the video element. * @param frameCallbacks - An object containing frame numbers as keys and callback functions as values. * @param options(optional) - An object containing options for the hook. * @return {void} * */ export declare function useVideoFrame(props: useVideoFrameProps): void;