开发者

AvAudioRecorder settings configuration help

I want to record a .caf file then send it as a mail attachment and pick it up on my mac. The problem is the caf file is not playable outside my app, only in my app. What setting do i have to use to play the .caf file whit Quicktime on my mac here are my setting. I save the audio file in the iphone Documents directory.

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

I am using a external platform to send the attachment, i am sending it to a web server converted in base

        NSString *documentsDirectory = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
    NSString *filePath2 = [documentsDirectory stringByAppendingPathComponent:@"VoiceMail.caf"];
    attachment1.FileData = [serv convertFileToB64String:filePath2 fileName:@"Voi开发者_Python百科ceMail.caf"];
    attachment1.FileName = @"VoiceMail.caf";
    message.Attachments = [[NSMutableArray alloc] initWithObjects:attachment1, nil];


Try this setting, this should work.

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜