Skip to content

Audio not recording completely or unable to record audio #190

@c-info

Description

@c-info

Describe the bug
Audio recording on iOS is not working as expected — the recorded audio is either incomplete, very short, or missing entirely.

To Reproduce
Steps to reproduce the behavior:

  1. Set up the recorder with mode "live"
  2. Check permission
  3. Record audio for 20-30 s.
  4. Get the audio path and send it to the server. The actual recording size is 1-2 seconds only

Expected behavior
It should record complete audio.

Smartphone (please complete the following information):

  • Device: [iPhone 7]
  • OS: [iOS15.8.4 ]

Reproducable code

const {checkHasAudioRecorderPermission, getAudioRecorderPermission} =
    useAudioPermission();

  const [recorderState, setRecorderState] = useState(RecorderState.stopped);

  const startRecord = () => {
    recordRef.current
      ?.startRecord({
        updateFrequency: UpdateFrequency.high,
      })
      .then(() => {})
      .catch(() => {});
  };

  const handleRecorderAction = useCallback(async () => {
    if (recorderState === RecorderState.stopped) {
      let hasPermission = await checkHasAudioRecorderPermission();
      if (hasPermission === PermissionStatus.granted) {
        startRecord();
      } else if (hasPermission === PermissionStatus.undetermined) {
        const permissionStatus = await getAudioRecorderPermission();
        if (permissionStatus === PermissionStatus.granted) {
          startRecord();
        }
      } else {
        Linking.openSettings();
      }
    } else {
      recordRef.current?.stopRecord().then(path => {
        let type = mime.lookup(path.replace('file://', ''));
        console.log('path', path);
        onSendRecording({mime: type, path});
      });
    }
  }, [
    checkHasAudioRecorderPermission,
    getAudioRecorderPermission,
    onSendRecording,
    recorderState,
  ]);


<Waveform
          mode="live"
          containerStyle={[AppStyle.fill]}
          ref={recordRef}
          candleSpace={2}
          candleWidth={4}
          waveColor={Colors.primary500}
          onRecorderStateChange={setRecorderState}
        />

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions