hyochan / react-native-audio-recorder-player

react-native native module for audio recorder and player.
MIT License
681 stars 203 forks source link

Ios recorder audio is m4a and android recorded is mp4 #588

Open DevHamzaShahid opened 4 months ago

DevHamzaShahid commented 4 months ago

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

yernandus commented 4 months ago

same thing. android is recording mp4

LiuYiSong commented 3 months ago

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

TallNutAlt commented 3 months ago

the same

Irfan-S commented 3 months ago

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

TallNutAlt commented 3 months ago

通过在 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格式