Class

AVPlayerLooper

An object that simplifies the playing of looping media content using a queue player.

Declaration

@interface AVPlayerLooper : NSObject

Overview

You can manually implement looping playback in your app using AVQueuePlayer, but AVPlayerLooper provides a much simpler interface to loop a single AVPlayerItem. You create a player looper by passing it a reference to your AVQueuePlayer and a template AVPlayerItem and the looper automatically manages the looping playback of this content (see example).

AVAsset *asset = // AVAsset with its 'duration' property value loaded
AVPlayerItem *playerItem = [AVPlayerItem playerItemWithAsset:asset];
 
// Create a new player looper with the queue player and template item
self.playerLooper = [AVPlayerLooper playerLooperWithPlayer:self.queuePlayer
                                              templateItem:playerItem];
 
// Begin looping playback
[self.queuePlayer play];

Topics

Creating a Player Looper

- initWithPlayer:templateItem:timeRange:

Creates a player looper instance to repeat the specified time range of a player item using a queue player.

+ playerLooperWithPlayer:templateItem:timeRange:

Returns a player looper instance to repeat the specified time range of a player item using a queue player.

+ playerLooperWithPlayer:templateItem:

Returns a player looper instance configured to loop the full duration of the specified player item in the queue player.

Configuring the Player Looper

loopingPlayerItems

An array containing replicas of the template player item used to accomplish the looping.

- disableLooping

Disables looping for the player queue.

Observing Looper State

loopCount

The number of times the specified player item has been played.

status

A status indicating the loopers ability to be used for looping playback.

AVPlayerLooperStatus

The statuses that indicate whether a looper can successfully perform looping playback.

error

The error that caused looping to fail.

Relationships

Inherits From