From 6fd1db6c463fdc6b68f01f2c1c186cbc6902c273 Mon Sep 17 00:00:00 2001 From: Tarek Date: Fri, 13 Oct 2023 14:48:48 +0200 Subject: [PATCH] make loop & autoplay trigger reload --- src/components/shared/AudioViewer/index.tsx | 24 ++++----------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/src/components/shared/AudioViewer/index.tsx b/src/components/shared/AudioViewer/index.tsx index 1ff0c631..f29d1e9e 100644 --- a/src/components/shared/AudioViewer/index.tsx +++ b/src/components/shared/AudioViewer/index.tsx @@ -304,6 +304,7 @@ const AudioViewer = ({ if (!waveform.current) return; if (autoplay) waveform.current.play(); + (waveform.current.backend as unknown as WebAudio).media.loop = looping; }); @@ -368,7 +369,7 @@ const AudioViewer = ({ } else { redrawTimeline(timelineContainer.current, waveform.current); } - }, [url, peaks]); + }, [url, peaks, autoplay, looping]); const switchActiveWidget = () => { if (!waveform.current?.isReady) return; @@ -417,23 +418,6 @@ const AudioViewer = ({ } }; - const toggleRepeat = (enabled: boolean) => { - if (waveform.current?.isReady) { - if (!waveform.current) return; - - setLooping(enabled); - (waveform.current.backend as unknown as WebAudio).media.loop = enabled; - } - }; - - const toggleAutoPlay = (enabled: boolean) => { - if (waveform.current?.isReady) { - if (!waveform.current) return; - setAutoplay(enabled); - //waveform.current.backend.autoplay = true;//!waveform.current.autoplay; - } - }; - const fitToScreen = () => { if (!waveform.current?.isReady) return; @@ -598,8 +582,8 @@ const AudioViewer = ({ );