// /$$$$$$ /$$$$$$ /$$ /$$ /$$$$$$$$ /$$ /$$ /$$$$$$$$ /$$$$$$ /$$$$$ /$$$$$$ /$$$$$$$ // /$$__ $$|_ $$_/| $$ | $$| $$_____/ | $$$ /$$$| $$_____/ /$$__ $$ |__ $$ /$$__ $$| $$__ $$ // | $$ \__/ | $$ | $$ | $$| $$ | $$$$ /$$$$| $$ | $$ \ $$ | $$| $$ \ $$| $$ \ $$ // | $$ /$$$$ | $$ | $$ / $$/| $$$$$ | $$ $$/$$ $$| $$$$$ | $$$$$$$$ | $$| $$ | $$| $$$$$$$ // | $$|_ $$ | $$ \ $$ $$/ | $$__/ | $$ $$$| $$| $$__/ | $$__ $$ /$$ | $$| $$ | $$| $$__ $$ // | $$ \ $$ | $$ \ $$$/ | $$ | $$\ $ | $$| $$ | $$ | $$ | $$ | $$| $$ | $$| $$ \ $$ // | $$$$$$/ /$$$$$$ \ $/ | $$$$$$$$ | $$ \/ | $$| $$$$$$$$ | $$ | $$ | $$$$$$/| $$$$$$/| $$$$$$$/ // \______/ |______/ \_/ |________/ |__/ |__/|________/ |__/ |__/ \______/ \______/ |_______/ // // Hi, I'm Roland and i'm looking for a job. // Resume in /public/resume.pdf // roland.vrignon@roland.com // https://www.linkedin.com/in/roland-vrignon/ // 'use client'; import { FC, useEffect, useState, useRef } from 'react'; import Image from 'next/image'; interface CourtSceneProps { setNextScene: () => void; currentQuestion: string; reaction: string; round: number; } const CourtScene: FC = ({ setNextScene, currentQuestion, reaction, round }) => { const [showFirstImage, setShowFirstImage] = useState(true); const audioRef = useRef(null); const isPlayingRef = useRef(false); useEffect(() => { const playAudio = async () => { // Si déjà en train de jouer, on ne fait rien if (isPlayingRef.current || !currentQuestion) return; try { isPlayingRef.current = true; const response = await fetch('/api/voice', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ language: 'en', text: reaction !== '' ? reaction + currentQuestion : currentQuestion, role: 'judge' }) }); if (!response.ok) { throw new Error('Failed to generate audio'); } const audioBlob = await response.blob(); const audioUrl = URL.createObjectURL(audioBlob); if (audioRef.current) { audioRef.current.pause(); audioRef.current = null; } const audio = new Audio(audioUrl); audioRef.current = audio; audio.addEventListener('ended', () => { isPlayingRef.current = false; }); await audio.play(); } catch (error) { console.error('Error playing audio:', error); isPlayingRef.current = false; } }; playAudio(); return () => { isPlayingRef.current = false; if (audioRef.current) { audioRef.current.pause(); audioRef.current = null; } }; }, [currentQuestion, reaction]); const handleNextScene = () => { if (audioRef.current) { audioRef.current.pause(); audioRef.current = null; } setNextScene(); }; useEffect(() => { const timer = setTimeout(() => { setShowFirstImage(false); }, 2000); return () => clearTimeout(timer); }, []); return (
{/* Image de fond statique */} Background {/* Image superposée avec transition */}
Overlay
{/* Rectangle noir en bas */}

{reaction !== '' && round !== 1 ? reaction.replace(/\?/g, '') : ''}
{currentQuestion ? currentQuestion : '...'}

{/* Flèche à droite */}
); }; export default CourtScene;