record(atTime:forDuration:)
Records audio starting at a specific time for the indicated duration.
Declaration
func record(atTime time: TimeInterval, forDuration duration: TimeInterval) -> BoolParameters
- time:
The time at which to start recording, relative to Devicecurrenttime.
- duration:
The duration of time to record, in seconds.
Return Value
Discussion
The recorder automatically stops recording when it reaches the indicated duration. You may also use it to synchronize recording of multiple recorders as shown below.
func startSynchronizedRecording() {
// Create a start time relative to the current device time.
let time = recorderOne.deviceCurrentTime + 0.01
let duration: TimeInterval = 10.0
// Synchronize recording of both recorders.
recorderOne.record(atTime: time, forDuration: duration)
recorderTwo.record(atTime: time, forDuration: duration)
}Calling this method implicitly calls prepareToRecord(), which creates an audio file and prepares the system for recording.