简体   繁体   中英

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?

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

Parameters duration The maximum duration, in seconds, for the recording.

Return Value true if successful, otherwise false.

Discussion The recorder stops when the duration of recorded audio reaches the value in the duration parameter.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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