<!--
{
  "availability" : [
    "iOS: 17.0.0 -",
    "iPadOS: 17.0.0 -",
    "macCatalyst: 17.0.0 -",
    "macOS: 14.0.0 -",
    "tvOS: 17.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AVFoundation",
  "identifier" : "/documentation/AVFoundation/AVPlayerLooper/init(player:templateItem:timeRange:existingItemsOrdering:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "AVFoundation"
    ],
    "preciseIdentifier" : "c:objc(cs)AVPlayerLooper(im)initWithPlayer:templateItem:timeRange:existingItemsOrdering:"
  },
  "title" : "init(player:templateItem:timeRange:existingItemsOrdering:)"
}
-->

# init(player:templateItem:timeRange:existingItemsOrdering:)

Creates a player looper that continuously plays the full duration of a player item while adhering to the specified ordering of existing items in the queue.

```
init(player: AVQueuePlayer, templateItem itemToLoop: AVPlayerItem, timeRange loopRange: CMTimeRange, existingItemsOrdering itemOrdering: AVPlayerLooper.ItemOrdering)
```

## Parameters

`player`

A queue player to control playback.

`itemToLoop`

A player item to loop.

`loopRange`

The player item time range to loop. Passing a value of <doc://com.apple.documentation/documentation/CoreMedia/CMTimeRange/invalid> is equivalent to a time range of [0, player item’s duration].

`itemOrdering`

A value that indicates whether the looper inserts replica items before or after existing items in the specified queue player.

## Discussion

The player looper doesn’t use the player item you specify for playback, and instead uses it as a template to create at least three player item replicas that it uses for looping playback. Because the looper only uses the player item as a template, any changes that you make to it after initialization aren’t reflected in the looping playback.

> Important:
> Load the ``doc://com.apple.avfoundation/documentation/AVFoundation/AVPartialAsyncProperty/duration`` value of a player item’s asset before passing the item to the looper to prevent blocking the calling thread until the duration is known.

## Topics

### Item ordering

[`AVPlayerLooper.ItemOrdering`](/documentation/AVFoundation/AVPlayerLooper/ItemOrdering)

Constants that define the ordering of items in a player looper.



---

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)