Class

AVPlayerLayer

AVPlayerLayer 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.

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:

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
    }
}

Symbols

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 isReadyForDisplay: 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 videoGravity: String

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

var videoRect: CGRect

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

var pixelBufferAttributes: [String : Any]?

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

Relationships

Inherits From

Conforms To