Swift/AVFoundationQueuePlayer-iOS/PlayerView.swift

/*
    Copyright (C) 2016 Apple Inc. All Rights Reserved.
    See LICENSE.txt for this sample’s licensing information
    
    Abstract:
    Player view backed by an AVPlayerLayer.
*/
 
import UIKit
import AVFoundation
 
/// A simple `UIView` subclass that is backed by an `AVPlayerLayer` layer.
class PlayerView: UIView {
    var player: AVPlayer? {
        get {
            return playerLayer.player
        }
        
        set {
            playerLayer.player = newValue
        }
    }
    
    var playerLayer: AVPlayerLayer {
        return layer as! AVPlayerLayer
    }
 
    override class var layerClass: AnyClass {
        return AVPlayerLayer.self
    }
}