横屏不变形

This commit is contained in:
bluesea 2024-04-30 16:04:16 +08:00
parent 2148dcb241
commit 9810af4c01

View File

@ -156,14 +156,14 @@ class ZZHCustomPlayer: UIView {
// avPlayer?.allowsExternalPlayback = true
// avPlayer?.usesExternalPlaybackWhileExternalScreenIsActive = true
// avPlayer?.externalPlaybackVideoGravity = .resizeAspect
// avPlayer.
avPlayer?.addPeriodicTimeObserver(forInterval: CMTime(value: 1, timescale: self.avPlayer?.currentItem?.duration.timescale ?? 600), queue: DispatchQueue.main, using: {[weak self] ct in
self?.updateSliderUI(ct: ct)
})
avPlayerLayer = AVPlayerLayer(player: avPlayer)
avPlayerLayer?.frame = CGRect(x: 0, y: 0, width: Int(playerWidth), height: playerHeight)
avPlayerLayer?.videoGravity = .resize
avPlayerLayer?.videoGravity = .resizeAspect
playerLayerBgView!.layer.addSublayer(avPlayerLayer!)
// playerLayerBgView?.backgroundColor = UIColor.red
// self.backgroundColor = .orange