如何在我的iPad上创建.mp3文件?

时间:2012-08-22 17:09:36

标签: ios mp3

  

可能重复:
  Recording mp3 instead of caf file

我想知道是否有任何可以帮助我处理我的问题。

我找到了在iPad上保存声音的方法。但到目前为止,我只创建了.caf文件。我可以创建.mp3文件吗?

提前致谢。 我附上了我的代码:



    NSArray *dirPaths;
    NSString *docsDir;

    dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    docsDir = [dirPaths objectAtIndex:0];

    NSString *soundFilePath = [docsDir stringByAppendingPathComponent:@"sound.caf"];
    NSURL *soundFileURL = [NSURL fileURLWithPath:soundFilePath];

    NSDictionary *recordSettings = [NSDictionary dictionaryWithObjectsAndKeys:
    [NSNumber numberWithInt:AVAudioQualityMin], AVEncoderAudioQualityKey, [NSNumber numberWithInt:16], AVEncoderBitRateKey, [NSNumber numberWithInt: 2], AVNumberOfChannelsKey, [NSNumber numberWithFloat:44100.0], AVSampleRateKey, nil];

    NSError *error = nil;
    AVAudioRecorder audioRecorder = [[AVAudioRecorder alloc] initWithURL:soundFileURL settings:recordSettings error:&error];

    if (error){
        NSLog(@"error: %@", [error localizedDescription]);
    } else {
        [audioRecorder prepareToRecord];
        [audioRecorder record];
    }

0 个答案:

没有答案