metatext/Views/UIKit/PlayerView.swift
Justin Mazzocchi ff8fd63e50
Organize views
2021-01-28 22:50:58 -08:00

36 lines
850 B
Swift

// Copyright © 2020 Metabolist. All rights reserved.
import AVKit
import UIKit
final class PlayerView: UIView {
override class var layerClass: AnyClass {
AVPlayerLayer.self
}
var player: AVPlayer? {
get { (layer as? AVPlayerLayer)?.player }
set { (layer as? AVPlayerLayer)?.player = newValue }
}
override init(frame: CGRect) {
super.init(frame: frame)
}
var videoGravity: AVLayerVideoGravity {
get { playerLayer.videoGravity }
set { playerLayer.videoGravity = newValue }
}
@available(*, unavailable)
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
private extension PlayerView {
var playerLayer: AVPlayerLayer {
// swiftlint:disable:next force_cast
layer as! AVPlayerLayer
}
}