use-video-interval
Version:
A React hook for executing a callback at customizable intervals during video playback.
35 lines (34 loc) • 954 B
TypeScript
import { useVideoIntervalProps } from '../types/use-video-interval';
/**
* useVideoInterval
*
* @example
* ```tsx
* import { useRef, useState } from 'react';
*
* function App() {
* const videoRef = useRef<HTMLVideoElement>( null );
* const [ showOverlay, setShowOverlay ] = useState( false );
*
* useVideoInterval( 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 intervalCallbacks - An object containing interval numbers as keys and callback functions as values.
* @param options(optional) - An object containing options for the hook.
* @return {void}
*
*/
export declare function useVideoInterval(props: useVideoIntervalProps): void;