Class

AVPlayerLayer

An object that manages a player's visual output.

Declaration

@interface AVPlayerLayer : CALayer

Overview

A convenient way of using AVPlayerLayer in iOS or tvOS is as the backing layer for a UIView as illustrated in the following code example:

// PlayerView.h
@interface PlayerView : UIView
@property AVPlayer *player;
@property (readonly) AVPlayerLayer *playerLayer;
@end
 
// PlayerView.m
@implementation PlayerView
- (AVPlayer *)player {
    return self.playerLayer.player;
}
 
- (void)setPlayer:(AVPlayer *)player {
    self.playerLayer.player = player;
}
 
// Override UIView method
+ (Class)layerClass {
    return [AVPlayerLayer class];
}
 
- (AVPlayerLayer *)playerLayer {
    return (AVPlayerLayer *)self.layer;
}
@end

Topics

Creating a Player Layer

+ playerLayerWithPlayer:

Creates a player layer to display the visual output of a specified player.

Configuring Player Layer Values

player

The player for which the player layer displays visual output.

readyForDisplay

A Boolean value that indicates whether the first video frame has been made ready for display for the current item of the associated player.

videoGravity

A value that specifies how the video is displayed within a player layer’s bounds.

AVLayerVideoGravity

A value that defines how the video is displayed within a layer’s bounds rectangle.

videoRect

The current size and position of the video image as displayed within the receiver's bounds.

pixelBufferAttributes

The client requirements for the visual output displayed in the player layer during playback.

AVMakeRectWithAspectRatioInsideRect

Returns a scaled rectangle that maintains the specified aspect ratio within a bounding rectangle.

Relationships

Inherits From

See Also

Media Playback

AVPlayer

An object that provides the interface to control the player’s transport behavior.

AVQueuePlayer

A player used to play a number of items in sequence.

AVPlayerItem

An object used to model the timing and presentation state of an asset played by the player.

AVPlayerItemMetadataCollector

An object used to capture the date range metadata defined for an HTTP Live Streaming asset.

AVPlayerItemTrack

An object used to modify the presentation state of an asset track being presented by a player.

AVSynchronizedLayer

An object used to synchronize with a specific player item.

AVPlayerMediaSelectionCriteria

An object that specifies the preferred languages and media characteristics for a player.

AVSampleBufferAudioRenderer

An object used to decompress audio and play compressed or uncompressed audio.

AVSampleBufferDisplayLayer

An object that displays compressed or uncompressed video frames.

AVSampleBufferRenderSynchronizer

An object used to synchronize multiple queued sample buffers to a single timeline.

AVRouteDetector

An object that detects the presences of media playback routes.