Which recorded audio format in iPhone supports and plays in android too

How do I record audio from iphone as follows:

//Setup the dictionary object with all the recording settings that this //Recording sessoin will use NSMutableDictionary* recordSetting = [[NSMutableDictionary alloc] init]; [recordSetting setValue :[NSNumber numberWithInt:kAudioFormatAppleIMA4] forKey:AVFormatIDKey]; [recordSetting setValue:[NSNumber numberWithFloat:44100.0] forKey:AVSampleRateKey]; [recordSetting setValue:[NSNumber numberWithInt: 2] forKey:AVNumberOfChannelsKey]; //Now that we have our settings we are going to instanciate an instance of our recorder instance. //Generate a temp file for use by the recording. NSDate *now = [NSDate dateWithTimeIntervalSinceNow:0]; NSString *caldate = [now description]; recordedTmpFile = [[NSString stringWithFormat:@"%@/%@.caf", DOCUMENTS_FOLDER, caldate] retain]; NSLog(@"Using File called: %@",recordedTmpFile); url = [NSURL fileURLWithPath:recordedTmpFile]; error = nil; //Setup the recorder to use this file and record to it. recorder = [[ AVAudioRecorder alloc] initWithURL:url settings:recordSetting error:&error]; 

But my problem is the application that I am developing is also developed for Android, but using a common server for iPhone and Android. When I publish the recorded sound from the iPhone to the server, and I tried to play that sound in Android, it shows a warning as an unsupported file.

Any help in what format should be recorded to play sound on iPhone and Android?

Any help would be greatly appreciated.

+4
source share
1 answer

It worked for me this way: its AAC format, which works on both, but when the sound is encoded on an Android device in AAC format, it needs to be placed in the .m4a container for it to play on ios. Its a simple extension change.

eg:

  On android device : morningtune.aac Now Just change the extension of the song On ios device : monrningtune.m4a 

First, on an Android device, I recorded audio with the following parameters

  recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4); recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC); 

Now just change the output audio extension to "m4a"

+1
source

All Articles