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

How to play audio before stop recording?

Open nHussain18 opened this issue 1 year ago • 5 comments

Please fill the template to help you out. Also, please try the Example project compare before submiting the issue when you have certain issue with your project setup.

Version of react-native-audio-recorder-player 3.5.3

Version of React Native 0.69.3

Platforms you faced the error (IOS or Android or both?) both

Expected behavior

audio should be play before stop recording

Actual behavior

audio file is not playing before stop recording

I am developing a chat application in which I want to implement audio record feature like whatsapp, when I call startRecorder it gives me the path of audio file, I want to play it when user pause recording, but it dont play any audio and dont giving any warning and error also.

if I call stopRecorder it also gives the file path and then I can play audio file but now I can not add more content to that file,

nHussain18 avatar Apr 24 '23 02:04 nHussain18

Were you able to find out any solution?

19BCS1114 avatar Sep 22 '23 10:09 19BCS1114

 const dirs = RNFetchBlob.fs.dirs.DocumentDir;
 const audioFileName = "sound.aac";
  const audioPath = "file://" + dirs + `/${audioFileName}`;

  const path = Platform.select({
    ios: audioPath,
    android: undefined
  });

This helped me

19BCS1114 avatar Sep 23 '23 11:09 19BCS1114

Hey, even I was not able to play audio without stopping but it was working for the audio config shared in the example.

` import AudioRecorderPlayer, { AVEncoderAudioQualityIOSType, AVEncodingOption, AudioEncoderAndroidType, AudioSet, AudioSourceAndroidType, OutputFormatAndroidType, } from 'react-native-audio-recorder-player';

const audioSet: AudioSet = { AudioEncoderAndroid: AudioEncoderAndroidType.AAC, AudioSourceAndroid: AudioSourceAndroidType.MIC, AVEncoderAudioQualityKeyIOS: AVEncoderAudioQualityIOSType.high, AVNumberOfChannelsKeyIOS: 2, AVFormatIDKeyIOS: AVEncodingOption.aac, OutputFormatAndroid: OutputFormatAndroidType.AAC_ADTS, };

// inside my react native component audioRecorderPlayer.startRecorder(undefined, audioSet)

`

RajRohitYadav avatar Nov 28 '23 11:11 RajRohitYadav

Is there a fix for this yet? because I'm having the exact same issue

Aycom366 avatar Jan 10 '24 15:01 Aycom366

 const dirs = RNFetchBlob.fs.dirs.DocumentDir;
 const audioFileName = "sound.aac";
  const audioPath = "file://" + dirs + `/${audioFileName}`;

  const path = Platform.select({
    ios: audioPath,
    android: undefined
  });

This helped me

I did exactly this, However, if you continue recording and pause again and you decide to listen to the audio. the end will be cut off.

do you have any fix for this?

Aycom366 avatar Jan 10 '24 20:01 Aycom366