<!--
{
  "availability" : [
    "iOS: 4.0.0 -",
    "iPadOS: 4.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.7.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AVFoundation",
  "identifier" : "/documentation/AVFoundation/AVPlayerLayer",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "AVFoundation"
    ],
    "preciseIdentifier" : "c:objc(cs)AVPlayerLayer"
  },
  "title" : "AVPlayerLayer"
}
-->

# AVPlayerLayer

An object that presents the visual contents of a player object.

```
class AVPlayerLayer
```

## Overview

A common way to use this object in iOS or tvOS is as the backing layer for a <doc://com.apple.documentation/documentation/UIKit/UIView>, as the following example shows:

```swift
/// A view that displays the visual contents of a player object.
class PlayerView: UIView {

    // Override the property to make AVPlayerLayer the view's backing layer.
    override static var layerClass: AnyClass { AVPlayerLayer.self }
    
    // The associated player object.
    var player: AVPlayer? {
        get { playerLayer.player }
        set { playerLayer.player = newValue }
    }
    
    private var playerLayer: AVPlayerLayer { layer as! AVPlayerLayer }
}
```

> Important:
> The value of a player layer’s inherited <doc://com.apple.documentation/documentation/QuartzCore/CALayer/contents> property is opaque and you can’t change it.

## Topics

### Creating a player layer

[`init(player:)`](/documentation/AVFoundation/AVPlayerLayer/init(player:))

Creates a layer object to present the visual contents of a player’s current item.

### Configuring the presentation

[`videoRect`](/documentation/AVFoundation/AVPlayerLayer/videoRect)

The current size and position of the video image that displays within the layer’s bounds.

[`videoGravity`](/documentation/AVFoundation/AVPlayerLayer/videoGravity)

A value that specifies how the layer displays the player’s visual content within the layer’s bounds.

[`AVLayerVideoGravity`](/documentation/AVFoundation/AVLayerVideoGravity)

A structure that defines how a layer displays a player’s visual content within the layer’s bounds.

### Determining display readiness

[`isReadyForDisplay`](/documentation/AVFoundation/AVPlayerLayer/isReadyForDisplay)

A Boolean value that indicates whether the first video frame of the player’s current item is ready for display.

### Accessing the player

[`player`](/documentation/AVFoundation/AVPlayerLayer/player)

The player whose visual content the layer displays.

### Processing pixel buffers

[`pixelBufferAttributes`](/documentation/AVFoundation/AVPlayerLayer/pixelBufferAttributes)

The attributes of the visual output that displays in the player layer during playback.

[`displayedPixelBuffer()`](/documentation/AVFoundation/AVPlayerLayer/displayedPixelBuffer())

Returns the pixel buffer that the player layer currently displays.

[`displayedReadOnlyPixelBuffer()`](/documentation/AVFoundation/AVPlayerLayer/displayedReadOnlyPixelBuffer())

Returns the pixel buffer which is currently being displayed.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)