我的iPhone应用程序在iOS10中运行良好,但在iOS11中无效。此应用程序将用户的语音记录为.wav文件,但其标题数据在iOS10和iOS11之间似乎有所不同。波形文件使用iOS10中的“fmt chunk”输出,但在iOS11中使用“JUNK chunk”输出。我需要在标头中指定fmt chunk。 这是输出wave文件的代码。
// Create file path.
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"yMMddHHmmss"];
NSString *fileName = [NSString stringWithFormat:@"%@.wav", [formatter stringFromDate:[NSDate date]]];
self.filePath = [NSTemporaryDirectory() stringByAppendingPathComponent:fileName];
// Change Audio category to Record.
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryRecord error:nil];
// Settings for AVAAudioRecorder.
NSDictionary *settings = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithUnsignedInt:kAudioFormatLinearPCM], AVFormatIDKey,
[NSNumber numberWithFloat:16000.0], AVSampleRateKey,
[NSNumber numberWithUnsignedInt:1], AVNumberOfChannelsKey,
[NSNumber numberWithUnsignedInt:16], AVLinearPCMBitDepthKey,
nil];
self.recorder = [[AVAudioRecorder alloc] initWithURL:[NSURL URLWithString:filePath] settings:settings error:nil];
recorder.delegate = self;
[recorder prepareToRecord];
[recorder record];
我真的需要你的帮助。谢谢。