react-native-sound-level icon indicating copy to clipboard operation
react-native-sound-level copied to clipboard

iOS: Conflict with other AVAudio player/recorder applications

Open ncstc1 opened this issue 2 years ago • 0 comments

Hi, I have two questions/comments on iOS:

Conflicts between AVAudio callers

It looks like AVAudioRecorder processing will stop (isRecording becomes false) if another application starts playing music.

Is there a way to avoid that? (by tweaking the current code or using another API? I am not sure another API returns metering information/averagePowerForChannel).

Making the timer collection more robust

When the application resumes after the previous problem, the metering processing should resume too (isRecording should become true again).

I am unsure about the right fix (hence no PR :)) but I considered something like:

(void)sendProgressUpdate {
  if (!_audioRecorder || !_audioRecorder.isRecording) {
    if (!_audioRecorder.isRecording) {
      // Restart the timer if the recording stopped for some reason
      [self stop];
      [self start:_progressUpdateInterval];
    }
    return;
  }
  (...)

What do you think?

ncstc1 avatar Dec 06 '22 17:12 ncstc1