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(() => {
if (sound) {
if (!hasLoaded) {
if (!hasLoaded && !isLoading) {
setIsLoading(true);
sound.load();
}
sound.play();
if (!sound.playing()) {
sound.play();
}
}
}, [sound, hasLoaded]);
}, [sound, hasLoaded, isLoading]);
const stop = useCallback(() => {
if (sound) sound.stop();