123456789101112131415161718192021222324252627282930313233343536 |
- import {useEffect, useRef} from 'react';
- interface AutoplayVideoProps extends React.VideoHTMLAttributes<HTMLVideoElement> {
- 'aria-label': string;
- }
- function AutoplayVideo(props: AutoplayVideoProps) {
- const videoRef = useRef<HTMLVideoElement>(null);
- useEffect(() => {
- if (videoRef.current) {
-
-
-
-
- videoRef.current.muted = true;
-
- videoRef.current.play()?.catch(() => {
-
- });
- }
- }, []);
- return <video ref={videoRef} playsInline disablePictureInPicture loop {...props} />;
- }
- export {AutoplayVideo};
|