简体   繁体   English

record(forDuration:) 方法自行停止

[英]record(forDuration:) method stops on its own

I just want to verify whether the method record(forDuration:) will record the audio for this specified amount of time and then stop the recording on its own without me calling explicitly stop(), is this correct?我只是想验证方法 record(forDuration:) 是否会在这段指定的时间内录制音频,然后在没有我显式调用 stop() 的情况下自行停止录制,这是正确的吗?

func startRecording(){

        do{
            let audioURL = self.getAudioURL()
             print("first \(audioURL)")
            audioRecorder = try AVAudioRecorder(url:self.getAudioURL(),settings:settings)
            audioRecorder.delegate = self
            audioRecorder.record(forDuration: 15)
        }catch{
            finishRecording(success: false)
        }
    }

Thank you very much.非常感谢。

Yes, see below from documentation:是的,请参阅以下文档:

Declaration宣言

func record(forDuration duration: TimeInterval) -> Bool func 记录(forDuration 持续时间:TimeInterval)-> Bool

Parameters duration The maximum duration, in seconds, for the recording.参数 duration 录制的最长持续时间,以秒为单位。

Return Value true if successful, otherwise false.返回值 如果成功,则返回 true,否则返回 false。

Discussion The recorder stops when the duration of recorded audio reaches the value in the duration parameter.讨论当录制音频的持续时间达到 duration 参数中的值时,录音机停止。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM