Skip to content

Commit

Permalink
error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
mathildedd committed Dec 3, 2024
1 parent 19741a6 commit bf69270
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,20 @@ type HeroVideoSubtitles = {
} & DefaultParams;

const MuxVideoComponent = ({ lang, translations }: HeroVideoSubtitles) => {
const [error, setError] = useState<Error | null>(null);
const [isLoading, setIsLoading] = useState(true);
const handleError = (e: Event) => {
setError(new Error('Failed to load video'));
setIsLoading(false);
};

useEffect(() => {
const video = videoElementRef.current;
if (video) {
video.addEventListener('error', handleError);
return () => video.removeEventListener('error', handleError);
}
}, []);
const videoElementRef = useRef<HTMLVideoElement>(null);
const posterRef = useRef<HTMLDivElement>(null);
const [muted, setMuted] = useState(true);
Expand Down

0 comments on commit bf69270

Please sign in to comment.