---
title: "record(atTime:forDuration:)"
framework: avfaudio
role: symbol
role_heading: Instance Method
path: "avfaudio/avaudiorecorder/record(attime:forduration:)"
---

# record(atTime:forDuration:)

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

## Declaration

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

## Parameters

- `time`: The time at which to start recording, relative to doc://com.apple.avfaudio/documentation/AVFAudio/AVAudioRecorder/deviceCurrentTime.
- `duration`: The duration of time to record, in seconds.

## Return Value

Return Value true if recording was successful; otherwise, false.

## Discussion

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

- [prepareToRecord()](avfaudio/avaudiorecorder/preparetorecord().md)
- [record()](avfaudio/avaudiorecorder/record().md)
- [record(atTime:)](avfaudio/avaudiorecorder/record(attime:).md)
- [record(forDuration:)](avfaudio/avaudiorecorder/record(forduration:).md)
- [pause()](avfaudio/avaudiorecorder/pause().md)
- [stop()](avfaudio/avaudiorecorder/stop().md)
- [isRecording](avfaudio/avaudiorecorder/isrecording.md)
- [deleteRecording()](avfaudio/avaudiorecorder/deleterecording().md)
