AVPlayerLayer
An object that presents the visual contents of a player object.
Declaration
class AVPlayerLayerMentioned in
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 }
}