I'm working on a React Native application which plays back voicemails. I'm running into an issue with our production app. It does not play back the voicemails on the production iOS or testflight builds, however it will play back on the production build of android as well as the emulator for iOS and Android. I'm relatively new to react-native applications so I'm trying to figure out why this would be occurring.
The app does not crash, it shows the playback as occurring in the UI but no audio is played.
What are specific things to check regarding a production build not being able to play sound?
I am on the current version of react-native-sound which is currently 0.10.9.
Here is my togglePlay function which uses Sound from react-native-sound. I have imported it.
togglePlay() {
if (this.state.vmLoaded == false) { if (this.state.vmLoading == true) { return; } if (this.state.vmLoading == false) { this.setState({ vmLoading: true }); Requester.getVoicemail(this.props.vmData, this.props.token, 'stream') .then((res) => { this.setState({ vmPath: res, vmLoaded: true, }); const vm = new Sound(res, '', (error) => { if (error) { // Show toast if voicemail did not load Toast({ message: 'Failed to load voicemail' }); } else { if (!this.state.vmStarted) { this.setState({ vmStarted: true }); } vm.play((success) => { if (success) { this.setState({ vmPlaying: false, currentTime: this.state.vmLength / 1000, }); // Clears the interval timer to keep thread // from keeping track of timing timer.clearInterval(this, 'playingInt'); } else { // if call recording fails to play, show toast to user Toast({ message: 'Failed to play recording' }); } }); this.setState({ vmPlaying: true }); // if loaded successfully, set the instance of Sound as STATE vm // allowing calls to the instance via this.state.vm // ie: this.state.vm.play() will initiate playing the sound this.setState({ // set instance of Sound to state vm, // set full length of recording to state vmLength: vm.getDuration(), // set current playing time of recording to state (new, so zero) currentTime: 0, // interval is still null until sound is played interval: null, // sound starts off paused (no audio) vmPlaying: true, // Finally, the recording has been loaded, setting // this so another instance is not created on // rerender (see above IF statements) vmLoaded: true, vmLoading: false, }); } }); }).then(() => { timer.clearInterval(this, 'playingInt'); interval: timer.setInterval(this, 'playingInt', () => { this.state.vm.getCurrentTime((seconds) => { this.setState({ currentTime: seconds }); }); }, 1000); }); } } else if (this.state.vmLoaded == true) { if (this.state.vmPlaying == true) { this.state.vm.pause(); this.setState({ vmPlaying: false }); timer.clearInterval(this, 'playingInt'); } else { this.state.vm.play(); this.setState({ vmPlaying: true }); timer.clearInterval(this, 'playingInt'); interval: timer.setInterval(this, 'playingInt', () => { this.state.vm.getCurrentTime((seconds) => { this.setState({ currentTime: seconds }); }); }, 1000); } }}
Please let me know if other information would be helpful in debugging this.
Thank you