mirror of
https://github.com/remvze/moodist.git
synced 2025-12-17 08:54:13 +00:00
fix: remove extra play calls
This commit is contained in:
parent
cf7600e6c7
commit
e0164c362d
1 changed files with 5 additions and 3 deletions
|
|
@ -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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!sound.playing()) {
|
||||||
sound.play();
|
sound.play();
|
||||||
}
|
}
|
||||||
}, [sound, hasLoaded]);
|
}
|
||||||
|
}, [sound, hasLoaded, isLoading]);
|
||||||
|
|
||||||
const stop = useCallback(() => {
|
const stop = useCallback(() => {
|
||||||
if (sound) sound.stop();
|
if (sound) sound.stop();
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue