在录音中播放和暂停

时间:2014-11-14 08:37:46

标签: objective-c xcode avfoundation

我想在我的应用中使用录音。我做了录音播放,暂停和停止。但是在录制片段之后我想要倒带它再次播放它以查看它们是否说了所有内容,然后再次继续录制。这在iOS中是否可行。

- (IBAction)recordPauseTapped:(id)sender {
    if (player.playing) {
        [player stop];
    }

    if (!recorder.recording) {
        AVAudioSession *session = [AVAudioSession sharedInstance];
        [session setActive:YES error:nil];

        // Start recording
        [recorder record];
        [recordPauseButton setTitle:@"Pause" forState:UIControlStateNormal];

    } else {

        // Pause recording
        [recorder pause];
        [recordPauseButton setTitle:@"Record" forState:UIControlStateNormal];
    }

    [stopButton setEnabled:YES];
    [playButton setEnabled:NO];
}

- (IBAction)stopTapped:(id)sender {
    [recorder stop];

    AVAudioSession *audioSession = [AVAudioSession sharedInstance];
    [audioSession setActive:NO error:nil];
}

- (IBAction)playTapped:(id)sender {
    if (!recorder.recording){
        player = [[AVAudioPlayer alloc] initWithContentsOfURL:recorder.url error:nil];
        [player setDelegate:self];
        [player play];
    }
}

如果有办法,请告诉我。

0 个答案:

没有答案