fix: remove extra play calls

This commit is contained in:
MAZE 2023-11-28 16:00:53 +03:30
parent cf7600e6c7
commit e0164c362d

View file

@ -40,14 +40,16 @@ export function useSound(
const play = useCallback(() => { const play = useCallback(() => {
if (sound) { if (sound) {
if (!hasLoaded) { if (!hasLoaded && !isLoading) {
setIsLoading(true); setIsLoading(true);
sound.load(); sound.load();
} }
sound.play(); if (!sound.playing()) {
sound.play();
}
} }
}, [sound, hasLoaded]); }, [sound, hasLoaded, isLoading]);
const stop = useCallback(() => { const stop = useCallback(() => {
if (sound) sound.stop(); if (sound) sound.stop();