react-native-audio-recorder-player
react-native-audio-recorder-player copied to clipboard
Ios recorder audio is m4a and android recorded is mp4
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
same thing. android is recording mp4
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
the same
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
通过在 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格式