【问题标题】:Continue recording an audio after interrupting by phone call, AVAudioRecorder被电话打断后继续录制音频,AVAudioRecorder
【发布时间】:2019-05-25 10:24:25
【问题描述】:

被来电打断后如何继续录音?现在来电后我的录音停止了,但我希望能够恢复录音

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 {

      }

    }

【问题讨论】:

    标签: swift audio-recording avaudiorecorder


    【解决方案1】:

    使用

    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 从这里恢复

    【讨论】:

    • 是的,我知道,但是我应该在哪里添加呢?在什么功能?
    • 谢谢回答,你知道具体怎么做吗
    • 你错了,我应该用applicationWillResignActive代替applicationWillEnterForeground
    猜你喜欢
    • 1970-01-01
    • 2012-02-14
    • 1970-01-01
    • 2011-03-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多