通过电话AVAudioRecorder中断后继续录制音频

时间:2019-05-25 10:24:26

标签: swift audio-recording avaudiorecorder

在打进电话中断后如何继续录制音频?现在,来电后我的记录停止了,但是我希望能够继续记录

func audioRecorderDidFinishRecording(_ recorder: AVAudioRecorder,
                                     successfully flag: Bool) {

    if flag {
        recorder.stop()
        isRecording = false
        recordButton.setImage(#imageLiteral(resourceName: "RecButtonRecord"), for: .normal)
        playButton.isEnabled = true
        playButton.alpha = 1
        titleRecordTextView.isHidden = false
        sourceRecordTextView.isHidden = false

    }
    else {

      }

    }

1 个答案:

答案 0 :(得分:0)

使用

recorder.pause()

暂停 recording,您必须选中

通过 AppDelegate 方法进行管理

 func applicationWillEnterForeground(_ application: UIApplication) {
        // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
    }

,您必须使用NotificationCenter从此处恢复