cleanup sounds that are done playing

This commit is contained in:
Joeri Exelmans 2025-10-26 12:54:02 +01:00
parent 08dc096792
commit 25fbb26fd7
2 changed files with 4 additions and 1 deletions

View file

@ -406,7 +406,7 @@ export function App() {
flex: '0 0 content',
overflowY: "auto",
overflowX: "visible",
maxWidth: '50vw',
maxWidth: 'min(400px, 50vw)',
}}>
<div className="stackVertical" style={{height:'100%'}}>
<div

View file

@ -36,6 +36,9 @@ export function useAudioContext(speed: number) {
src.loop = loop;
src.start();
setSounds(sounds => [...sounds, src]);
src.addEventListener("ended", () => {
setSounds(sounds => sounds.filter(s => s !== src));
})
return src;
});
// return callback to stop playing