import { useStateRef } from '@past3lle/hooks' import React, { useEffect, useState } from 'react' import { SmartVideo, SmartVideoProps } from './index' function SmartVideoWrapper(props: SmartVideoProps) { const [playing, setPlaying] = useState(true) const [ref, setRef] = useStateRef(null, (node) => node) const showCtrlBtn = !props.autoPlayOptions || props.autoPlayOptions.stopTime < (ref?.currentTime || 0) useEffect(() => { if (!ref) return const isPlaying = playing if (isPlaying) { ref.play() } else { ref.pause() } }, [ref, playing]) return ( <> setPlaying((playing) => !playing)} /> ) } const container = document.createElement('div') export default { default: ( ), showTapToPlay: ( alert('Video clicked')} /> ), autoStop: ( ) }