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

Ios recorder audio is m4a and android recorded is mp4

Open DevHamzaShahid 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

"react-native-audio-recorder-player": "^3.6.6",

Version of React Native"

"react-native": "0.73.1",

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

in android

Expected behavior

Ios recorded audio is m4a which should also play in android

Actual behavior

android recorded audio is playing in both platforms as it is recorded with extension mp4 but ios recorded m4a audio is only playable on ios not when we play that audio in android as i am working on chat app, so ios users are sending audio chat to android user then android users are unable to play

Steps to reproduce the behavior

DevHamzaShahid avatar Feb 16 '24 19:02 DevHamzaShahid

same thing. android is recording mp4

yernandus avatar Feb 25 '24 12:02 yernandus

Yes, this is a very big problem. If Android and iOS files cannot be played together, it will be meaningless, so it is urgent to solve this problem

LiuYiSong avatar Mar 09 '24 17:03 LiuYiSong

the same

TallNutAlt avatar Mar 18 '24 08:03 TallNutAlt

By saving files as .AAC on both iOS and Android, this issue can be worked around.

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

This can then be passed in as a prop during recording, which then works on both devices

Irfan-S avatar Mar 22 '24 11:03 Irfan-S

通过在 iOS 和 Android 上将文件保存为 .AAC,可以解决此问题。

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

然后可以在录制期间将其作为道具传入,然后在两个设备上都可以使用

const audioSet = { AudioEncoderAndroid: AudioEncoderAndroidType.AAC, AudioSourceAndroid: AudioSourceAndroidType.MIC, AVEncoderAudioQualityKeyIOS: AVEncoderAudioQualityIOSType.high, AVNumberOfChannelsKeyIOS: 2, AVFormatIDKeyIOS: AVEncodingOption.aac, }; audioRecorderPlayer.startRecorder(undefined,audioSet).then(res => { console.log(res); setNextYuyin(true); }); 我尝试了一下 并没有变成 aac格式

TallNutAlt avatar Apr 01 '24 02:04 TallNutAlt