From 7db37f8aed44faa82699f82f54215c6cd6217cad Mon Sep 17 00:00:00 2001 From: Evert-R Date: Wed, 8 May 2024 13:38:36 +0200 Subject: [PATCH] Clear buffers before preloading first section unless previous section was the same --- frontend/src/components/Preload/Preload.jsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/Preload/Preload.jsx b/frontend/src/components/Preload/Preload.jsx index 5241469f9..9e50b8da0 100644 --- a/frontend/src/components/Preload/Preload.jsx +++ b/frontend/src/components/Preload/Preload.jsx @@ -41,6 +41,11 @@ const Preload = ({ sections, playMethod, duration, preloadMessage, pageTitle, on } return; } + + // Clear buffers if this is the first section + if (index === 0) { + webAudio.clearBuffers(); + } // Load sections in buffer return webAudio.loadBuffer(section.id, section.url, () => { @@ -66,8 +71,6 @@ const Preload = ({ sections, playMethod, duration, preloadMessage, pageTitle, on } preloadResources(); - // on destroy, clean up buffers - return webAudio.clearBuffers(); }, [sections, playMethod, onNext]); return (