'use client'; import { FC, useEffect, useState } 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); useEffect(() => { const playAudio = async () => { try { if (!currentQuestion) return; const response = await fetch('/api/voice', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ language: 'en', // You may want to make this configurable 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); const audio = new Audio(audioUrl); audio.play(); } catch (error) { console.error('Error playing audio:', error); } }; if (currentQuestion) { playAudio(); } // eslint-disable-next-line react-hooks/exhaustive-deps }, [currentQuestion]); 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;