react-native-audio-recorder-player icon indicating copy to clipboard operation
react-native-audio-recorder-player copied to clipboard

How to configure this library in ios RN-Cli

Open zenesys0081 opened this issue 11 months ago • 1 comments

I have added the already permissions.

And i am try to setup the IOS manually than show this error in Xcode #import "React/RCTBridgeModule.h" this file not found show error .

And Adding the following under "Build Settings" -> "Header Search Paths". $(SRCROOT)/../node_modules/react-native/React

But this error not solve..

And this code working in android but i am trying to record in iOS i am facing this error very time this--

  1. ERROR Error in micHandler: [Error: Error occurred during recording]
  2. ERROR Error in micHandler: [Error: Failed to stop recorder. It is already nil.]
  3. ERROR Error uploading audio: [TypeError: Network request failed]

---------------------------------- This code is android perfectly working but IOS not working -------------------------------- const micHandler = async () => { const baseDir = ${RNFS.DocumentDirectoryPath}/cinch-all-audio;

try {
  if (!isRecording) {
    await RNFS.mkdir(baseDir, {NSURLIsExcludedFromBackupKey: true});
    const fileName = `${Date.now()}.mp3`;
    const audioPath = `${baseDir}/${fileName}`;
    const audioSet = {
      AudioEncoderAndroid: AudioEncoderAndroidType.AAC,
      AudioSourceAndroid: 6,
    };

    // Start recording
    const result = await audioRecorderPlayer.startRecorder(
      audioPath,
      audioSet,
    );
    setIsRecording(true);
  } else {
    const result = await audioRecorderPlayer.stopRecorder();
    setIsRecording(false);

    const parts = result.split('/');
    const fileName = parts[parts.length - 1];
    const reference = ref(storage, `/${'recordedAudio'}/${fileName}`);
    const pathToFile = result;

    try {
      const fileData = await fetch(pathToFile).then(response =>
        response.blob(),
      );
      const uploadAudioFile = await uploadBytes(reference, fileData);

      if (uploadAudioFile) {
        const audioURL = await getDownloadURL(reference);
       console.log(audioURL);
      } else {
        console.error('File upload failed');
      }
    } catch (error) {
      console.error('Error uploading audio:', error);
    }
  }
} catch (error) {
  console.error('Error in micHandler:', error);
  alert(error);
}

};

zenesys0081 avatar Sep 16 '23 11:09 zenesys0081

i faced some issue, fixed by changing extension from .mp3 -> .m4a. I dont know why but on ios mp3 doesnt work. On android it also NO issues with m4a.

Also make sure to grant permissions to write document directory on ios.

zhekaqq avatar Sep 17 '23 18:09 zhekaqq