From d2971870c1c7a9c7c5d20ab73d2df34ac90f319d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20FAMIBELLE-PRONZOLA?= Date: Sat, 4 Jul 2026 11:45:22 +0400 Subject: [PATCH] =?UTF-8?q?fix:=20corriger=20les=20bugs=20du=20lecteur=20a?= =?UTF-8?q?udio=20(rendus,=20effets=20dupliqu=C3=A9s)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/teks/lekte.js | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/components/teks/lekte.js b/components/teks/lekte.js index c17ebc4..fce23b4 100644 --- a/components/teks/lekte.js +++ b/components/teks/lekte.js @@ -75,9 +75,12 @@ const TinyText = styled(Typography)({ }) export default function Lekte({audio, url, parole}) { - const audioRef = useRef(createAudio(audio)) + const audioRef = useRef(null) + if (audioRef.current === null) { + audioRef.current = createAudio(audio) + } + const intervalRef = useRef() - const isReady = useRef(false) const [duration, setDuration] = useState(0) const theme = useTheme() const {mode} = useColorScheme() @@ -104,25 +107,9 @@ export default function Lekte({audio, url, parole}) { clearInterval(intervalRef.current) intervalRef.current = setInterval(() => { setPosition(Math.round(audioRef.current.currentTime)) - }, [1000]) + }, 1000) } - useEffect(() => { - if (isReady.current) { - audioRef.current.play() - setIsPlaying(true) - startTimer() - } - }, []) - - useEffect(() => { - if (isPlaying) { - audioRef.current.play() - } else { - audioRef.current.pause() - } - }, [isPlaying]) - useEffect(() => () => { audioRef.current.pause() @@ -132,7 +119,7 @@ export default function Lekte({audio, url, parole}) { useEffect(() => { if (isPlaying) { - audioRef.current.play() + audioRef.current.play().catch(() => {}) startTimer() } else { clearInterval(intervalRef.current)