zmxv / react-native-sound

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

When I send voice note from android to IOS, then failed to load sound in IOS. #841

Open akshaySimublade opened 6 days ago

akshaySimublade commented 6 days ago

:beetle: Description

:beetle: What is the observed behavior?

When I send a voice note from android to ios, then in ios that voice note is loading. Error -> {"code": "ENSOSSTATUSERRORDOMAIN2003334207", "domain": "NSOSStatusErrorDomain", "message": "The operation couldn’t be completed. (OSStatus error 2003334207.)", "nativeStackIOS": ["0 OPAR-Development 0x00000001055150b8 RCTJSErrorFromCodeMessageAndNSError + 112", "1 OPAR-Development 0x0000000105515008 RCTJSErrorFromNSError + 236", "2 OPAR-Development 0x0000000105408954 -[RNSound prepare:withKey:withOptions:withCallback:] + 1288", "3 CoreFoundation 0x000000019c23d814 00E76A98-210C-3CB5-930B-F236807FF24C + 133140", "4 CoreFoundation 0x000000019c23c860 00E76A98-210C-3CB5-930B-F236807FF24C + 129120", "5 CoreFoundation 0x000000019c2b31dc 00E76A98-210C-3CB5-930B-F236807FF24C + 614876", "6 OPAR-Development 0x00000001054baf84 -[RCTModuleMethod invokeWithBridge:module:arguments:] + 1796", "7 OPAR-Development 0x00000001054bf020 _ZN8facebook5reactL11invokeInnerEP9RCTBridgeP13RCTModuleDatajRKN5folly7dynamicEiN12_GLOBALN_117SchedulingContextE + 1688", "8 OPAR-Development 0x00000001054be7bc _ZZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEiENK3$0clEv + 128", "9 OPAR-Development 0x00000001054be730 ZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEi_block_invoke + 28", "10 libdispatch.dylib 0x00000001a414413c 81D355DF-266A-3010-BAB8-113B76A206C1 + 8508", "11 libdispatch.dylib 0x00000001a4145dd4 81D355DF-266A-3010-BAB8-113B76A206C1 + 15828", "12 libdispatch.dylib 0x00000001a414d400 81D355DF-266A-3010-BAB8-113B76A206C1 + 46080", "13 libdispatch.dylib 0x00000001a414df30 81D355DF-266A-3010-BAB8-113B76A206C1 + 48944", "14 libdispatch.dylib 0x00000001a4158cb4 81D355DF-266A-3010-BAB8-113B76A206C1 + 93364", "15 libdispatch.dylib 0x00000001a4158528 81D355DF-266A-3010-BAB8-113B76A206C1 + 91432", "16 libsystem_pthread.dylib 0x00000001f90f7934 _pthread_wqthread + 288", "17 libsystem_pthread.dylib 0x00000001f90f40cc start_wqthread + 8"], "userInfo": {}}

Same voice note is working fine on android from which I have send it to IOS. If i sent voice note from IOS to android, then also it is working fine in both devices android and IOS. Error occurs only when I send sound note from android to IOS, then In IOS, sound file not loading.

:beetle: What is the expected behavior?

:beetle: Please post your code:

            const path = RNFS.CachesDirectoryPath +'/upload.mp4'

            RNFS.writeFile(path, item?.voiceNote, 'base64').then(() => playSound(),
              console.log("checkkknoooooo",path)

            )
            // const localWavPath = await decodeOpus(item?.voiceNote);

            const playSound = () => {

                // Sound.setCategory('Playback');
                                        //  /Users/mac/Library/Developer/CoreSimulator/Devices/8E6CD5CD-54C8-4853-B65C-1FC8FEF4B413/data/Containers/Data/Application/334DD96F-2430-45A1-8F1C-365D76A0A6C4/Library/Caches/upload.mp4
                item.audio = new Sound(path,'', (error) => {
                    if (error) {
                        console.log('failed to load the sound ', error);
                        return;
                    }
                    // loaded successfully

                    currrentAudio = item.audio
                    const tempArray = [...userMessage]
                    const index = tempArray.findIndex((element) => element.time === messageId)
                    tempArray[index].isPlaying = true
                    console.log("check the array", tempArray);
                    setUserMessage(tempArray)
                    item?.audio.play((success) => {
                        if (success) {
                            console.log('successfully finished playing');
                            const tempArray = [...userMessage]
                            const index = tempArray.findIndex((element) => element.time === messageId)
                            tempArray[index].isPlaying = false
                            setUserMessage(tempArray)

                        } else {
                            console.log('playback failed due to audio decoding errors');
                        }
                    });
                })
            }
            // const callback = () => sound.play(successCallback)
            // return;
// Please post your code

:bulb: Does the problem have a test case?

:bulb: **Possible solution**

:bulb: Is there a workaround?

:bulb: If the bug is confirmed, would you be willing to create a pull request?

Is your issue with...

Are you using...

Which versions are you using?

Does the problem occur on... Device

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