zmxv / react-native-sound

React Native module for playing sound clips
MIT License
2.78k stars 748 forks source link

Facing issue in react-native-sound latest version 0.11.1 in iOS "The operation couldn’t be completed. (OSStatus error -2003334207.)" #774

Open dippathak26 opened 2 years ago

dippathak26 commented 2 years ago

Facing issue in react-native-sound latest version 0.11.1 "The operation couldn’t be completed. (OSStatus error -2003334207.)"

I have used react-native-sound version 0.11.1 and playing sound from local (i.e. in Android -> res/raw and in iOS -> Resource folders respectively). I have also tried to downgrade to the older version 0.11.0 as it was working well, but still I am facing the same issue. Please check below code:

const soundBundle = Platform.OS === 'ios' ? encodeURIComponent(Sound.MAIN_BUNDLE) // also used empty string("") and null, but getting the same output : Sound.MAIN_BUNDLE; sound = new Sound(audioUrl, soundBundle, error => { if (error) { console.log('failed to load the sound ====>>>>>>', error); } else { console.log('sound loaded'); } });

:bulb: Is there a workaround?

Is your issue with...

Are you using...

Which versions are you using?

Does the problem occur on...

If your problem is happening on a device, which device?

amjadbouhouch commented 2 years ago

Hi @dippathak26 any update ?

dippathak26 commented 2 years ago

@amjadbouhouch Hi, I have no update yet, but I have found another solution for playing the sound. You can check out the beloiw link for that:

https://www.npmjs.com/package/react-native-video

gilshaan commented 2 years ago

Pass second argument as '' for ios and Sound.DOCUMENT or other values for android. Please see the below code

var whoosh = new Sound(path + '/audio/test.mp3', Platform.OS === 'ios' ? '' : Sound.DOCUMENT, (error) => {
                  if (error) {
                    console.log('failed to load the sound', error);
                    return;
                  }
                });
leovazquezz1 commented 2 years ago

For us what worked was adding the sound to the root directory (not the Resource directory), downgrading to version 0.11.0 (not 0.11.2) and encoding the uri

Sargnec commented 1 year ago

64 https://github.com/zmxv/react-native-sound/issues/64#issuecomment-753434422

Try this solution too you might need to encode Sound.MAIN_BUNDLE