An object that simplifies the playing of looping media content using a queue player.
SDKs
- iOS 10.0+
- macOS 10.12+
- Mac Catalyst 13.0+
- tvOS 10.0+
Framework
- AVFoundation
Declaration
class AVPlayerLooper : NSObject
Overview
You can manually implement looping playback in your app using AVQueue
, but AVPlayer
provides a much simpler interface to loop a single AVPlayer
. You create a player looper by passing it a reference to your AVQueue
and a template AVPlayer
and the looper automatically manages the looping playback of this content (see example).
let asset = // AVAsset with its 'duration' property value loaded
let playerItem = AVPlayerItem(asset: asset)
// Create a new player looper with the queue player and template item
playerLooper = AVPlayerLooper(player: queuePlayer, templateItem: playerItem)
// Begin looping playback
queuePlayer.play()