Home > database >  React Native Sound Error: Argument 1 (RCTResponseSenderBlock) of RNSound.play must not be null
React Native Sound Error: Argument 1 (RCTResponseSenderBlock) of RNSound.play must not be null

Time:10-13

As far as I can tell I am loading the correct resource. However when I try to play the sound using React Native Sound I am still getting the following error:

Argument 1 (RCTResponseSenderBlock) of RNSound.play must not be null

How to fix this error?

I've checked the variables holding the sound object and it looks like it is loaded:

 LOG  this.outgoingCall {"_duration": 18.1811875, "_filename": "http://localhost:8081/assets/assets/sounds/dialing.mp3?platform=ios&hash=717d95726264d7105360ce45119c9e0e", "_key": 35, "_loaded": true, "_numberOfChannels": 2, "_numberOfLoops": 0, "_pan": 0, "_pitch": 1, "_playing": false, "_speed": 1, "_volume": 1, "onPlaySubscription": {"remove": [Function remove]}, "registerOnPlay": [Function anonymous]}
 LOG  this.incomingCall {"_duration": 5.224458333333334, "_filename": "http://localhost:8081/assets/assets/sounds/calling.mp3?platform=ios&hash=0707a09b5a0268a9cb3e6f9b8d5b32ec", "_key": 36, "_loaded": true, "_numberOfChannels": 2, "_numberOfLoops": 0, "_pan": 0, "_pitch": 1, "_playing": false, "_speed": 1, "_volume": 1, "onPlaySubscription": {"remove": [Function remove]}, "registerOnPlay": [Function anonymous]}
 LOG  this.endCall {"_duration": 1.306, "_filename": "http://localhost:8081/assets/assets/sounds/end_call.mp3?platform=ios&hash=90aad40264cc274ce67046ab241054c0", "_key": 37, "_loaded": true, "_numberOfChannels": 2, "_numberOfLoops": 0, "_pan": 0, "_pitch": 1, "_playing": false, "_speed": 1, "_volume": 1, "onPlaySubscription": {"remove": [Function remove]}, "registerOnPlay": [Function anonymous]}

If you just continue until the end you will see the error when clicking the call button...

The sample code of ConnectyCube works perfectly but it uses old react navigation. Below is the link for ConnectyCube sample code:

https://github.com/ConnectyCube/connectycube-reactnative-samples/tree/master/RNVideoChatConf

I basically just used the latest react navigation but the rest of the code is the same as the sample code of connectycube however it doesn't work the same....I am getting the React Native Sound Error...

CodePudding user response:

There's not much that can be done here except to look at and trust the error. It says the argument must not be null.

I would take the info from this error message and check to see if you are passing in null to the play method during the first render of a component somewhere.

It's possible you have a state value or a prop somewhere that is null only on the first render, and obtains its value from a useEffect or similar method after play has been called.

CodePudding user response:

This isn't the best answer but it worked nevertheless. In the sample code package.json had: "react-native-sound": "^0.11.0", When I encountered the problem I was using the latest and newest version of react-native-sound 0.11.X

I originally installed just using npm i react-native-sound and accepted whatever version it gave me which I assume is the latest and newest version.

After getting stuck with the above problem I decided to install the exact same code version via: npm install [email protected] and that solved the problem....

  • Related