| 3 | import {VideoHTMLAttributes} from 'react'; |
| 4 | |
| 5 | export function Video(props: VideoHTMLAttributes<HTMLVideoElement>) { |
| 6 | return ( |
| 7 | // eslint-disable-next-line |
| 8 | <video |
| 9 | {...props} |
| 10 | tabIndex={props.autoPlay && !props.controls ? 0 : undefined} |
| 11 | onClick={e => { |
| 12 | if (props.autoPlay && !props.controls) { |
| 13 | e.currentTarget.paused ? e.currentTarget.play() : e.currentTarget.pause(); |
| 14 | } |
| 15 | }} |
| 16 | onKeyDown={e => { |
| 17 | if (props.autoPlay && !props.controls && e.key === ' ') { |
| 18 | e.preventDefault(); |
| 19 | e.currentTarget.paused ? e.currentTarget.play() : e.currentTarget.pause(); |
| 20 | } |
| 21 | }} |
| 22 | /> |
| 23 | ); |
| 24 | } |