3

对于录制声音,我使用以下代码:

- (IBAction) recordClicked:(id)sender {
    NSLog(@"play Record");
    if (audioPlayerRecord) {
        if (audioPlayerRecord.isPlaying) [audioPlayerRecord stop];
        else {
            [audioPlayerRecord play];
            [self updateCurrentTimeForPlayer:audioPlayerRecord];
        }
        return;
    } 

    //Initialize playback audio session
    AVAudioSession *audioSession = [AVAudioSession sharedInstance];
    [audioSession setCategory:AVAudioSessionCategoryPlayback error:nil];

    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *recDir = [paths objectAtIndex:0];
    NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/recordTest.caf", recDir]];

    NSError *error;
    audioPlayerRecord = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];
    [audioPlayerRecord play];
    duration.text = [NSString stringWithFormat:@"%d:%02d", (int)audioPlayerRecord.duration / 60, (int)audioPlayerRecord.duration % 60, nil];
    progressBar.maximumValue = audioPlayerRecord.duration;
    [self updateViewForPlayerState:audioPlayerRecord];
    NSLog(@"Recoder file >");
}

当录音正在进行时,我想显示以下类型的电平表

电平表

那么有没有其他简化的方法来解决这个问题呢?

4

1 回答 1

0

检查 AQRecorder.mm ...

寻找:void AQRecorder::StartRecord(CFStringRef inRecordFile)

在这里你必须评论/删除de line

url = CFURLCreateWithString(kCFAllocatorDefault, (CFStringRef)recordFile, NULL);

url = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, (CFStringRef)recordFile, kCFURLPOSIXPathStyle, false);
于 2013-01-07T13:27:01.890 回答