cleanup sounds that are done playing
This commit is contained in:
parent
08dc096792
commit
25fbb26fd7
2 changed files with 4 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue