如何在 ios 8 中使用 avaudiorecorder 录制 .mp2 格式文件?

How to record .mp2 formate file using avaudiorecorder in ios 8?

全部 我要录制mp2文件。

var 记录设置 = [ AVFormatIDKey: kAudioFormatMPEGLayer2, AVEncoderAudioQualityKey : AVAudioQuality.Max.toRaw(), AVEncoderBitRateKey : 320000, AVNumberOfChannelsKey:2, AVSampleRateKey:44100.0 ]

我的录音设置如上写在代码中(swift)。 但应用程序崩溃。我遇到错误, "The operation couldn’t be completed(OSStatus error 1718449215)"

检查:https://developer.apple.com/library/ios/documentation/AudioVideo/Conceptual/MultimediaPG/UsingAudio/UsingAudio.html#//apple_ref/doc/uid/TP40009767-CH2-SW49 可用的录制格式。 MPEG Layer I、II 和 III 不在列表中。如果您使用例如 kAudioFormatMPEG4AAC,它将起作用。

已编辑:顺便说一下,了解错误代码的含义。例如“1718449215”——将其转换为十六进制字符串——你将得到“66 6d 74 3f”。即对应ascii字符'fmt?'