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...
It looks like in your javascript the .play()
method in v0.11.1 requires a callback due to this commit
https://github.com/zmxv/react-native-sound/commit/ed05fb96f06bbdfc83499b6ced04043f90fbf07d (which removes the default callback).
It might be fixed in a future release, or the documentation might be updated to change the method signature to require the callback.
For now you can add a callback and the error should go away
.play((success)=> console.log(success))
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....
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With