---
title: AVPlayerLayer
framework: avfoundation
role: symbol
role_heading: Class
path: avfoundation/avplayerlayer
---

# AVPlayerLayer

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

## Declaration

```swift
class AVPlayerLayer
```

## Mentioned in

Selecting subtitles and alternative audio tracks

## Overview

Overview A common way to use this object in iOS or tvOS is as the backing layer for a UIView, as the following example shows: /// 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 contents property is opaque and you can’t change it.

## Topics

### Creating a player layer

- [init(player:)](avfoundation/avplayerlayer/init(player:).md)

### Configuring the presentation

- [videoRect](avfoundation/avplayerlayer/videorect.md)
- [videoGravity](avfoundation/avplayerlayer/videogravity.md)
- [AVLayerVideoGravity](avfoundation/avlayervideogravity.md)

### Determining display readiness

- [isReadyForDisplay](avfoundation/avplayerlayer/isreadyfordisplay.md)

### Accessing the player

- [player](avfoundation/avplayerlayer/player.md)

### Processing pixel buffers

- [pixelBufferAttributes](avfoundation/avplayerlayer/pixelbufferattributes.md)
- [displayedPixelBuffer()](avfoundation/avplayerlayer/displayedpixelbuffer().md)
- [displayedReadOnlyPixelBuffer()](avfoundation/avplayerlayer/displayedreadonlypixelbuffer().md)

### Instance Methods

- [setCaptionPreviewProfileID(_:position:text:)](avfoundation/avplayerlayer/setcaptionpreviewprofileid(_:position:text:).md)
- [stopShowingCaptionPreview()](avfoundation/avplayerlayer/stopshowingcaptionpreview().md)

## Relationships

### Inherits From

- [CALayer](quartzcore/calayer.md)

### Conforms To

- [CAMediaTiming](quartzcore/camediatiming.md)
- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSCoding](foundation/nscoding.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)
- [NSSecureCoding](foundation/nssecurecoding.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)

## See Also

### Presentation

- [Monitoring playback progress in your app](avfoundation/monitoring-playback-progress-in-your-app.md)
- [Using HEVC video with alpha](avfoundation/using-hevc-video-with-alpha.md)
- [AVSynchronizedLayer](avfoundation/avsynchronizedlayer.md)
