<!--
{
  "availability" : [
    "iOS: 6.0.0 -",
    "iPadOS: 6.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.8.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AVFoundation",
  "identifier" : "/documentation/AVFoundation/AVPlayer/setRate(_:time:atHostTime:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AVFoundation"
    ],
    "preciseIdentifier" : "c:objc(cs)AVPlayer(im)setRate:time:atHostTime:"
  },
  "title" : "setRate(_:time:atHostTime:)"
}
-->

# setRate(_:time:atHostTime:)

Synchronizes the playback rate and time of the current item with an external source.

```
nonisolated func setRate(_ rate: Float, time itemTime: CMTime, atHostTime hostClockTime: CMTime)
```

## Parameters

`rate`

The playback rate for the item.

`itemTime`

The precise time at which to match playback of the item. To use the current item’s current time, specify <doc://com.apple.documentation/documentation/CoreMedia/CMTime/invalid>.

`hostClockTime`

The host time at which to synchronize playback. If you specify <doc://com.apple.documentation/documentation/CoreMedia/CMTime/invalid>, the rate and time are set together without any external synchronization.

## Discussion

This method adjusts the current item’s timebase so that the time in `itemTime` is in sync with the time in `hostClockTime`. Thus, if `hostClockTime` specifies a time in the past, the item’s timebase is adjusted to make it appear as if the item has been running at the specified rate since `itemTime`. And if `hostClockTime` specifies a time in the future, playback is adjusted backward (if possible) so that the value in `itemTime` occurs at the precise moment the host’s clock reaches the value in `hostClockTime`. If there is no content to play before the time specified by `itemTime`, playback holds until the two times come into sync.

This method does not ensure that media data is loaded before the timebase starts moving. However, if you specify a host time in the near future, that would give you some time to load the media data and prepare for playback.

> Important:
> The value of ``doc://com.apple.avfoundation/documentation/AVFoundation/AVPlayer/automaticallyWaitsToMinimizeStalling`` must be set to `false` before calling this method. If the property value is `true`, calling this method results in the system raising an invalid argument exception.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)