react-native-audio-recorder-player icon indicating copy to clipboard operation
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"

Open CRupesh opened this issue 3 years ago • 3 comments

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

CRupesh avatar Mar 24 '22 07:03 CRupesh

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!

flogy avatar May 16 '22 10:05 flogy

I had the same issue - thanks @flogy !

connorpmullins avatar May 30 '22 14:05 connorpmullins

Thanks, @flogy. I'll consider supporting better error messages.

Please give PR if possible.

hyochan avatar Oct 15 '22 12:10 hyochan