AvAudioRecorder设置配置帮助

Rad*_*adu 5 iphone xcode objective-c avaudiorecorder

我想记录一个.caf文件,然后将其作为邮件附件发送,并在我的Mac上取出.问题是caf文件不能在我的应用程序之外播放,只能在我的应用程序中播放.我必须使用什么设置来播放.caf文件,我的mac上的Quicktime是我的设置.我将音频文件保存在iphone文档目录中.

 NSDictionary *settings =[NSDictionary dictionaryWithObjectsAndKeys:
                            [NSNumber numberWithInt: kAudioFormatAppleLossless],    AVFormatIDKey,
                            [NSNumber numberWithFloat: 44100.0],                 AVSampleRateKey,
                            [NSNumber numberWithInt: 2],                         AVNumberOfChannelsKey,
                            [NSNumber numberWithInt:128000],                     AVEncoderBitRateKey,
                            [NSNumber numberWithInt: AVAudioQualityMax],         AVEncoderAudioQualityKey,
                          nil];
Run Code Online (Sandbox Code Playgroud)

我正在使用外部平台发送附件,我将其发送到基站转换的Web服务器

        NSString *documentsDirectory = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
    NSString *filePath2 = [documentsDirectory stringByAppendingPathComponent:@"VoiceMail.caf"];
    attachment1.FileData = [serv convertFileToB64String:filePath2 fileName:@"VoiceMail.caf"];
    attachment1.FileName = @"VoiceMail.caf";
    message.Attachments = [[NSMutableArray alloc] initWithObjects:attachment1, nil];
Run Code Online (Sandbox Code Playgroud)

Bab*_*oot 9

尝试此设置,这应该工作.

   NSMutableDictionary* recordSetting = [[NSMutableDictionary alloc] init];

    [recordSetting setValue :[NSNumber numberWithInt:kAudioFormatLinearPCM] forKey:AVFormatIDKey]; 
    [recordSetting setValue:[NSNumber numberWithFloat:9500.0] forKey:AVSampleRateKey]; 
    [recordSetting setValue:[NSNumber numberWithInt: 2] forKey:AVNumberOfChannelsKey];
    [recordSetting setValue:[NSNumber numberWithInt:AVAudioQualityHigh] forKey:AVEncoderAudioQualityKey];
    [recordSetting setValue :[NSNumber numberWithInt:16] forKey:AVLinearPCMBitDepthKey];
    [recordSetting setValue :[NSNumber numberWithBool:NO] forKey:AVLinearPCMIsBigEndianKey];
    [recordSetting setValue :[NSNumber numberWithBool:NO] forKey:AVLinearPCMIsFloatKey];
Run Code Online (Sandbox Code Playgroud)