Code: Select all
import { Button } from '@/components/ui/button';
import { useEffect, useState } from 'react';
interface DidAvatarProps {
resultUrl?: string;
handleCallDisconnect: () => void;
onAudioCompletion: () => void;
}
const DidAvatar = ({ resultUrl, handleCallDisconnect, onAudioCompletion }: DidAvatarProps) => {
const idleVideo = '/assets/didAnimation/maryIdle.mp4';
const [videoSrc, setVideoSrc] = useState(resultUrl || idleVideo);
useEffect(() => {
// Whenever resultUrl changes, reset the video source
if (resultUrl) {
setVideoSrc(resultUrl);
} else {
setVideoSrc(idleVideo);
}
}, [resultUrl]);
const handleEnded = () => {
setVideoSrc(idleVideo);
onAudioCompletion();
};
return (
Fist video
);
};
export default DidAvatar;
Was ich möchte:
Wenn ein Video endet und ich ein neues Ergebnis aus dem Server erhalte, sollte er sofort ohne Flash/Glitch abspielen.>