zmxv / react-native-sound

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

Failed to load sounds in IOS #723

Closed minafa96 closed 3 years ago

minafa96 commented 3 years ago

:beetle: Description

sounds play fine in android but in ios I'm getting this error

 failed to load the sound {"code": "ENSOSSTATUSERRORDOMAIN2003334207", "domain": "NSOSStatusErrorDomain", "message": "The operation couldn’t be completed. (OSStatus error 2003334207.)", "nativeStackIOS": ["0   deenee                              0x000000010e2f8ea7 RCTJSErrorFromCodeMessageAndNSError + 135", "1   deenee                              0x000000010e2f8dd3 RCTJSErrorFromNSError + 275", "2   deenee                              0x000000010e1d9ded -[RNSound prepare:withKey:withOptions:withCallback:] + 1949", "3   CoreFoundation                      0x00007fff204282fc __invoking___ + 140", "4   CoreFoundation                      0x00007fff204257b6 -[NSInvocation invoke] + 303", "5   CoreFoundation                      0x00007fff20425a47 -[NSInvocation invokeWithTarget:] + 70", "6   deenee                              0x000000010e282714 -[RCTModuleMethod invokeWithBridge:module:arguments:] + 2660", "7   deenee                              0x000000010e2868be _ZN8facebook5reactL11invokeInnerEP9RCTBridgeP13RCTModuleDatajRKN5folly7dynamicE + 814", "8   deenee                              0x000000010e286386 _ZZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEiENK3$_0clEv + 134", "9   deenee                              0x000000010e2862ec ___ZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEi_block_invoke + 28", "10  libdispatch.dylib                   0x00000001110747ec _dispatch_call_block_and_release + 12", "11  libdispatch.dylib                   0x00000001110759c8 _dispatch_client_callout + 8", "12  libdispatch.dylib                   0x000000011107c296 _dispatch_lane_serial_drain + 796", "13  libdispatch.dylib                   0x000000011107cf67 _dispatch_lane_invoke + 439", "14  libdispatch.dylib                   0x0000000111088de2 _dispatch_workloop_worker_thread + 882", "15  libsystem_pthread.dylib             0x00007fff611684c0 _pthread_wqthread + 314", "16  libsystem_pthread.dylib             0x00007fff61167493 start_wqthread + 15"], "userInfo": {}}

:beetle: Please post your code:


function PlaySound(name) {
  const voice = new Sound(name, Sound.MAIN_BUNDLE, (error) => {
    if (error) {
      console.warn('failed to load the sound', error);
    }
    if (voice) {
        voice.play((success) => {
          if (success) voice.release();
          else console.warn('faild to play the sound');
        });
      }
    });
}

Is your issue with...

IOS

Are you using...

React Native CLI

Which versions are you using?

Does the problem occur on...

Simulator

gulsher7 commented 3 years ago

same here anyone found solution ?

alienware commented 3 years ago

If the audio file you are using isn't added to the bundle, i.e., it isn't a local file that has been configured in Xcode resources, you'll get this error. Use null instead of Sound.MAIN_BUNDLE if the audio file is loaded over the wire.

marciok commented 3 years ago

Check your audio format, iOS does not support ogg files 😞

77TecShaeer commented 3 years ago

+++

anhquan291 commented 3 years ago

Follow this and it works !!!! https://github.com/zmxv/react-native-sound/issues/64#issuecomment-346956562

atulmala commented 3 years ago

If the audio file you are using isn't added to the bundle, i.e., it isn't a local file that has been configured in Xcode resources, you'll get this error. Use null instead of Sound.MAIN_BUNDLE if the audio file is loaded over the wire.

This worked for me!

minafa96 commented 3 years ago

for me, the problem was that I didn't add .mp3 to the name