---
title: "seek(to:toleranceBefore:toleranceAfter:completionHandler:)"
framework: avfoundation
role: symbol
role_heading: Instance Method
path: "avfoundation/avplayeritem/seek(to:tolerancebefore:toleranceafter:completionhandler:)"
---

# seek(to:toleranceBefore:toleranceAfter:completionHandler:)

Sets the current playback time within a specified time bound and invokes the specified block when the seek operation completes or is interrupted.

## Declaration

```swift
nonisolated func seek(to time: CMTime, toleranceBefore: CMTime, toleranceAfter: CMTime, completionHandler: (@Sendable (Bool) -> Void)? = nil)
```

```swift
nonisolated func seek(to time: CMTime, toleranceBefore: CMTime, toleranceAfter: CMTime) async -> Bool
```

## Parameters

- `time`: The time to which to seek.
- `toleranceBefore`: The temporal tolerance before time. Pass doc://com.apple.documentation/documentation/CoreMedia/CMTime/zero to request sample accurate seeking (this may incur additional decoding delay).
- `toleranceAfter`: The temporal tolerance after time. Pass doc://com.apple.documentation/documentation/CoreMedia/CMTime/zero to request sample accurate seeking (this may incur additional decoding delay).
- `completionHandler`: The block to invoke when the seek operation has finished.

## Discussion

Discussion Use this method to seek to a specified time for the item. The time seeked to will be within the range [time-toleranceBefore, time+toleranceAfter] and may differ from time for efficiency. Invoking this method with positiveInfinity for toleranceBefore and toleranceAfter is the same as invoking seek(to:completionHandler:) directly. Seeking is constrained by the collection of seekable time ranges. If you seek to a time outside all of the seekable ranges, the seek will result in a current time within the seekable ranges.

## See Also

### Seeking through media

- [seek(to:completionHandler:)](avfoundation/avplayeritem/seek(to:completionhandler:)-91gnw.md)
- [seek(to:completionHandler:)](avfoundation/avplayeritem/seek(to:completionhandler:)-1dibq.md)
- [cancelPendingSeeks()](avfoundation/avplayeritem/cancelpendingseeks().md)
