---
title: "init(player:templateItem:timeRange:existingItemsOrdering:)"
framework: avfoundation
role: symbol
role_heading: Initializer
path: "avfoundation/avplayerlooper/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.

## Declaration

```swift
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

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 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](avfoundation/avplayerlooper/itemordering.md)

## See Also

### Creating a player looper

- [init(player:templateItem:)](avfoundation/avplayerlooper/init(player:templateitem:).md)
- [init(player:templateItem:timeRange:)](avfoundation/avplayerlooper/init(player:templateitem:timerange:).md)
