【问题标题】:AvAudioRecorder settings configuration helpAvAudioRecorder 设置配置帮助
【发布时间】:2011-08-05 12:26:10
【问题描述】:

我想录制一个 .caf 文件,然后将其作为邮件附件发送并在我的 Mac 上提取。问题是 caf 文件在我的应用程序之外无法播放,只能在我的应用程序中播放。我必须使用什么设置才能在我的 Mac 上播放带有 Quicktime 的 .caf 文件,这是我的设置。我将音频文件保存在 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];

【问题讨论】:

    标签: iphone objective-c xcode avaudiorecorder


    【解决方案1】:

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

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

    【讨论】:

    • 我尝试了设置它仍然无法在我的应用程序之外播放
    • 我需要查看如何将此 .caf 文件附加到邮件附件的代码。
    • 我正在使用外部平台发送电子邮件附件,我将在几秒钟内将代码放入,
    • 我可能发现了错误,将消息发送到我的 Web 服务,我将其转换为 base64,我可能是问题所在,我在其他对象上使用了 base64 库并且工作完美,我会再试一次看看有什么问题。
    • 问题出在 base64 转换上,它在缓冲区中有一个错误,并且没有按应有的方式进行转换。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-05-11
    • 2011-10-26
    • 2011-07-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-13
    相关资源
    最近更新 更多