zmxv / react-native-sound

React Native module for playing sound clips

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Not working in conjunction with useEffect

jordangrant opened this issue · comments

Appreciate the work done here but ran into many issues playing sound effects while listening with useEffect ala:

 useEffect(() => {
       playSound(battle?.animation)
    }, [battle?.animation]);

and with .aac files crashing #802

and with the error "playback failed due to audio decoding errors"

tried useRef to no avail #728 (comment)

and different syntax, moved things around, you get the idea. tested on iOS device.

Had quicker and easier success with react-native-video: https://github.com/react-native-video/react-native-video

Thanks for the good times though

hi @jordangrant I think our issues are similar am trying to stop the current song when the user is leaving the screen.

which am doing inside a useEffect. but it not working.

did you find a solution around yours ?

@tdammy92 no solution with this library, simply using react-native-video with invisible views, and mp3, mp4 and m4a files works absolutely perfectly and great settings to control it too.

@jordangrant, Add the audio as part of the dependency. it should work

useEffect(() => {
playSound(battle?.animation)
}, [battle?.animation,audio]);