Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

As I am recording the audio from an 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, I am developing is also developed for Android but using common server for both iPhone and android. When I publish the recorded audio from iPhone to the server and I tried to play that audio in Android, it showing alert as not supported file.

Any help to which format should I record to play the audio in both iPhone and Android?

Anyone's help will be deeply appreciated.

like image 607
Monish Kumar Avatar asked Nov 13 '22 18:11

Monish Kumar


1 Answers

It worked for me this way: Its AAC format that works on both, but when the audio gets encoded on android device in AAC format, its needed to be put into the container of .m4a, to make it play on ios. Its simple change the extension.

eg:

    On android device :   morningtune.aac

    Now Just change the extension of the song


   On ios device :   monrningtune.m4a

First on Android device i recorded the audio with the following parameters

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

Now just change the extension of the output audio into "m4a"

like image 129
Kumar Vivek Mitra Avatar answered Dec 17 '22 04:12

Kumar Vivek Mitra