An object used to synchronize with a specific player item.
SDKs
- iOS 4.0+
- macOS 10.7+
- Mac Catalyst 13.0+
- tvOS 9.0+
Framework
- AVFoundation
Declaration
class AVSynchronizedLayer : CALayer
Overview
You can create an arbitrary number of synchronized layers from the same AVPlayer
object.
A synchronized layer is similar to a CATransform
object in that it doesn't display anything itself, it just confers state upon its layer subtree. AVSynchronized
confers its timing state, synchronizing the timing of layers in its subtree with that of a player item.
Any Core
layer with animation property set that is added as a sublayer of AVSynchronized
should set the animation's begin
property to a non-zero positive value so animations will be interpreted on the player item's timeline. Core
replaces the default begin
of 0.0 with CACurrent
. To start the animation from time 0, use a small positive value like AVCore
.
You might use a layer as shown in the following example:
AVPlayerItem *playerItem = <#Get a player item#>;
CALayer *superLayer = <#Get a layer#>;
// Set up a synchronized layer to sync the layer timing of its subtree
// with the playback of the playerItem/
AVSynchronizedLayer *syncLayer = [AVSynchronizedLayer synchronizedLayerWithPlayerItem:playerItem];
[syncLayer addSublayer:<#Another layer#>]; // These sublayers will be synchronized.
[superLayer addSublayer:syncLayer];