2

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?

ylongwu
  • 31
  • 1
  • 4
  • It works; In android just set to MPEG_4 and AAC and in iOS use initWithContentsOfURL . Some other problems led to not play in iOS. – ylongwu May 16 '16 at 09:05
  • This is not duplicate..This question not even related with the question that marked duplicate to – ken Nov 15 '17 at 05:54

0 Answers0