gpt4 book ai didi

iphone - AvAudioRecorder 设置配置帮助

转载 作者:太空狗 更新时间:2023-10-30 03:49:40 24 4
gpt4 key购买 nike

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

 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];

我正在使用外部平台发送附件,我正在将它发送到在 base 中转换的 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];

最佳答案

试试这个设置,应该可以。

   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];

关于iphone - AvAudioRecorder 设置配置帮助,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6956229/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com