Skip to content

Commit

Permalink
cleanup audio context on unmount (#23)
Browse files Browse the repository at this point in the history
* cleanup audio context on unmount

* minimize change

* cr

Co-authored-by: Samhir Tarif <[email protected]>

---------

Co-authored-by: Samhir Tarif <[email protected]>
  • Loading branch information
stephenarra and samhirtarif authored Sep 7, 2024
1 parent 4c36d75 commit a0dc505
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/LiveAudioVisualizer/LiveAudioVisualizer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,14 @@ const LiveAudioVisualizer: (props: Props) => ReactElement = ({
}
}, [analyser, context.state]);

useEffect(() => {
return () => {
if (context.state !== "closed") {
context.close();
}
}
}, []);

const processFrequencyData = (data: Uint8Array): void => {
if (!canvasRef.current) return;

Expand Down

0 comments on commit a0dc505

Please sign in to comment.