我想录制一个.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];
我正在使用外部平台发送附件,我将其发送到基本转换的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];
答案 0 :(得分: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];