react-native-audio-recorder-player
react-native-audio-recorder-player copied to clipboard
In IOS the app is getting crash with error "RNAudioRecorderPlayer/RNAudioRecorderPlayer.swift:429: Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value"
Code is as follows
await audioRecorderPlayer.startPlayer(path); audioRecorderPlayer.setVolume(1.0); audioRecorderPlayer.addPlayBackListener((e) => { if (e.currentPosition === e.duration) { audioRecorderPlayer.stopPlayer(); } });
Version of react-native-audio-recorder-player : 3.3.4
Version of React Native : 0.66.4
Platforms you faced the error (IOS or Android or both?) : IOS
I had the same issue and investigated a bit. Turns out this only happens when using react-native-audio-recorder-player with version 3.* as it was migrated to Swift.
The problem is that the audioPlayer variable is nil when there is no audio playing. It can be easily solved by making sure you only use setVolume in your code after starting to play an audio and not while it is not playing.
Error message could be improved though. Hope this helps!
I had the same issue - thanks @flogy !
Thanks, @flogy. I'll consider supporting better error messages.
Please give PR if possible.