2011-08-17 34 views
3

由於我從iPhone錄製音頻如下:什麼在iPhone錄製的音頻格式支持,並在Android中扮演過

//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]; 

但我的問題是應用程序,我開發也爲Android開發的,但爲iPhone和Android使用通用服務器。當我將錄製的音頻從iPhone發佈到服務器,並試圖在Android中播放音頻時,它會將警報顯示爲不受支持的文件。

我應該記錄哪種格式來播放iPhone和Android音頻的任何幫助?

任何人的幫助將深受讚賞。

回答

1

它適用於我這種方式:它的AAC格式適用於這兩種格式,但是當音頻在AAC格式的Android設備上編碼時,需要將其放入.m4a的容器中,以使其在ios上播放。它簡單的改變了擴展。

如:

On android device : morningtune.aac 

    Now Just change the extension of the song 


    On ios device : monrningtune.m4a 

第一個Android設備上我記錄以下參數

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

現在只是改變了輸出音頻的擴展成 「M4A」

音頻