metatext-app-ios-iphone-ipad/Views/UIKit/PlayerView.swift

37 lines
850 B
Swift
Raw Normal View History

2020-10-15 09:44:01 +02:00
// Copyright © 2020 Metabolist. All rights reserved.
import AVKit
import UIKit
2020-11-09 07:22:20 +01:00
final class PlayerView: UIView {
2020-10-15 09:44:01 +02:00
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)
2020-10-21 10:07:13 +02:00
}
2020-10-15 09:44:01 +02:00
2020-10-21 10:07:13 +02:00
var videoGravity: AVLayerVideoGravity {
get { playerLayer.videoGravity }
set { playerLayer.videoGravity = newValue }
2020-10-15 09:44:01 +02:00
}
@available(*, unavailable)
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
2020-10-21 10:07:13 +02:00
private extension PlayerView {
var playerLayer: AVPlayerLayer {
// swiftlint:disable:next force_cast
layer as! AVPlayerLayer
}
}