AVPlayer​Layer is a subclass of CALayer to which an AVPlayer object can direct its visual output. It can be used as the backing layer for a UIView or NSView or can be manually added to the layer hierarchy to present your video content on screen.


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

class PlayerView: UIView {
    var player: AVPlayer? {
        get {
            return playerLayer.player
        set {
            playerLayer.player = newValue
    var playerLayer: AVPlayerLayer {
        return layer as! AVPlayerLayer
    // Override UIView property
    override static var layerClass: AnyClass {
        return AVPlayerLayer.self


Creating a Player Layer

init(player:​ AVPlayer?)

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

Getting and Setting Player Layer Values

var player:​ AVPlayer?

The player for which the player layer displays visual output.

var is​Ready​For​Display:​ Bool

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

var video​Gravity:​ String

Specifies how the video is displayed within a player layer’s bounds.

var video​Rect:​ CGRect

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

var pixel​Buffer​Attributes:​ [String :​ Any]?

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


Inherits From