I have tried a variety of configurations in android, like:
myRecorder = new MediaRecorder();
myRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
myRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
myRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
myRecorder.setAudioSamplingRate(44100);
myRecorder.setAudioEncodingBitRate(256);
myRecorder.setAudioChannels(1);
and
MediaRecorder mediaRecorder = new MediaRecorder();
mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.HE_AAC);
mediaRecorder.setAudioSamplingRate(16000);
mediaRecorder.setAudioChannels(1);
and some others,but none of the voice recorded in android can be played in iOS. In iOS I tried:
self.player=[[AVAudioPlayer alloc]initWithContentsOfURL:fileUrl error:&error];
and
self.player=[[AVAudioPlayer alloc]initWithData:voicedata error:&error];
Both can not play the voice data. I also tried to change extension to .m4a or without extension,but no use.the error code is:
Error Domain=NSOSStatusErrorDomain Code=2003334207 "(null)"
It maybe a very common problem in Instant messaging app.
Is there something I need to change? Is there some kind of setting for NSData to specify what kind of file it is? Does anyone have any idea?