Contents

record(atTime:forDuration:)

Records audio starting at a specific time for the indicated duration.

Declaration

func record(atTime time: TimeInterval, forDuration duration: TimeInterval) -> Bool

Parameters

  • time:

    The time at which to start recording, relative to Devicecurrenttime.

  • duration:

    The duration of time to record, in seconds.

Return Value

true if recording was successful; otherwise, false.

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.

See Also

Controlling recording