2012-05-03 71 views
2

我在iOS上錄製的aac音頻文件存在一些問題。 我需要錄製音頻並使用AVPlayer播放。錄製工作正常,文件已創建。我可以在Mac上播放它。但是當我嘗試在AVPlayer中播放它(文件)時 - 沒有聲音。AQRecorder AAC在AVPlayer中播放

財產記錄音頻

mRecordFormat.mSampleRate  = 8000; 
mRecordFormat.mFormatID   = kAudioFormatMPEG4AAC; 
mRecordFormat.mFormatFlags  = kAudioFormatMPEG4AAC_LD; 
mRecordFormat.mFramesPerPacket = 0; 
mRecordFormat.mChannelsPerFrame = 1; 
mRecordFormat.mBitsPerChannel = 0; 
mRecordFormat.mBytesPerPacket = 0; 

我嘗試不同的設置,但沒有結果。請幫助

P.S.其他文件(MP3等)正常播放

回答

2

好吧,我找到幾年前的解決方案。 更改記錄的邏輯來

NSDictionary *settings = [NSDictionary dictionaryWithObjectsAndKeys: 
          [NSNumber numberWithInt:kAudioFormatMPEG4AAC], AVFormatIDKey, 
          [NSNumber numberWithFloat:16000], AVSampleRateKey, 
          [NSNumber numberWithInt:2], AVNumberOfChannelsKey, 
          [NSNumber numberWithInt:AVAudioQualityMedium], AVSampleRateConverterAudioQualityKey, 
          [NSNumber numberWithInt:64000], AVEncoderBitRateKey, 
          [NSNumber numberWithInt:8], AVEncoderBitDepthHintKey, 
          nil]; 


error = nil; 

_recorder = [[AVAudioRecorder alloc] initWithURL:url settings:settings error:&error]; 

,並在iOS,安卓和MacOS /贏得這個記錄文件播放。所以就是這樣。