zmxv / react-native-sound

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

AAC files are not played on IOS (OSStatus error 2003334207.) #802

Open brunovollmer opened 1 year ago

brunovollmer commented 1 year ago

:beetle: Description

I'm currently trying to play .aac audio files using the react-native-sound library. The same file works on Android with the same code. Additionally, I've also tried the converted version of the audio file to .wav and this also works. Any idea what I should look for?

:beetle: What is the observed behavior?

{"code": "ENSOSSTATUSERRORDOMAIN2003334207", "domain": "NSOSStatusErrorDomain", "message": "The operation couldn’t be completed. (OSStatus error 2003334207.)", "nativeStackIOS": ["0 Biped 0x00000001016cdfbc RCTJSErrorFromCodeMessageAndNSError + 112", "1 Biped 0x00000001016cdf0c RCTJSErrorFromNSError + 236", "2 Biped 0x00000001015db688 -[RNSound prepare:withKey:withOptions:withCallback:] + 1280", "3 CoreFoundation 0x0000000180412840 __invoking___ + 144", "4 CoreFoundation 0x000000018040fa24 -[NSInvocation invoke] + 276", "5 CoreFoundation 0x000000018040fcbc -[NSInvocation invokeWithTarget:] + 60", "6 Biped 0x000000010166d9d4 -[RCTModuleMethod invokeWithBridge:module:arguments:] + 1744", "7 Biped 0x00000001016712ec _ZN8facebook5reactL11invokeInnerEP9RCTBridgeP13RCTModuleDatajRKN5folly7dynamicEiN12_GLOBAL__N_117SchedulingContextE + 1108", "8 Biped 0x0000000101670cbc _ZZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEiENK3$_0clEv + 144", "9 Biped 0x0000000101670c20 ___ZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEi_block_invoke + 28", "10 libdispatch.dylib 0x0000000180133fa4 _dispatch_call_block_and_release + 24", "11 libdispatch.dylib 0x0000000180135768 _dispatch_client_callout + 16", "12 libdispatch.dylib 0x000000018013d7f8 _dispatch_lane_serial_drain + 780", "13 libdispatch.dylib 0x000000018013e43c _dispatch_lane_invoke + 392", "14 libdispatch.dylib 0x000000018014a624 _dispatch_workloop_worker_thread + 772", "15 libsystem_pthread.dylib 0x00000001ae55eb40 _pthread_wqthread + 284", "16 libsystem_pthread.dylib 0x00000001ae55d904 start_wqthread + 8"], "userInfo": {}}

:beetle: What is the expected behavior?

Play the file normally

:beetle: Please post your code:

const tmpAudio = new Sound(audioPath, Sound.MAIN_BUNDLE, error => {
      if (error) {
        console.log(error)
        console.log(audioPath)
      }
    })

Is your issue with...

Are you using...

Which versions are you using?

Does the problem occur on...

I also posted the Issue on StackOverflow: https://stackoverflow.com/questions/74043872/react-native-sound-aac-files-are-not-played-on-ios-osstatus-error-2003334207

adriandiaz commented 1 year ago

I had the same issue but if I replace Sound.MAIN_BUNDLE with null then it works

showtan001 commented 1 year ago
Sound.MAIN_BUNDLE

There is no null, only undefined, and there is no callback to simulate the play method

phuctranba commented 1 year ago

You can make audioPath => decodeURI(audioPath) and Sound.MAIN_BUNDLE into "" (empty string) for IOS