cleanup sounds that are done playing
This commit is contained in:
parent
08dc096792
commit
25fbb26fd7
2 changed files with 4 additions and 1 deletions
|
|
@ -406,7 +406,7 @@ export function App() {
|
||||||
flex: '0 0 content',
|
flex: '0 0 content',
|
||||||
overflowY: "auto",
|
overflowY: "auto",
|
||||||
overflowX: "visible",
|
overflowX: "visible",
|
||||||
maxWidth: '50vw',
|
maxWidth: 'min(400px, 50vw)',
|
||||||
}}>
|
}}>
|
||||||
<div className="stackVertical" style={{height:'100%'}}>
|
<div className="stackVertical" style={{height:'100%'}}>
|
||||||
<div
|
<div
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,9 @@ export function useAudioContext(speed: number) {
|
||||||
src.loop = loop;
|
src.loop = loop;
|
||||||
src.start();
|
src.start();
|
||||||
setSounds(sounds => [...sounds, src]);
|
setSounds(sounds => [...sounds, src]);
|
||||||
|
src.addEventListener("ended", () => {
|
||||||
|
setSounds(sounds => sounds.filter(s => s !== src));
|
||||||
|
})
|
||||||
return src;
|
return src;
|
||||||
});
|
});
|
||||||
// return callback to stop playing
|
// return callback to stop playing
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue