Workaround for AVPlayerViewController controls not respecting safe area
Closes #176
This commit is contained in:
parent
319b5458fc
commit
7474969969
|
@ -10,14 +10,30 @@ import UIKit
|
|||
import AVKit
|
||||
import Pachyderm
|
||||
|
||||
class GalleryPlayerViewController: AVPlayerViewController {
|
||||
class GalleryPlayerViewController: UIViewController {
|
||||
|
||||
let playerVC = AVPlayerViewController()
|
||||
|
||||
var attachment: Attachment!
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
allowsPictureInPicturePlayback = true
|
||||
view.backgroundColor = .black
|
||||
|
||||
playerVC.allowsPictureInPicturePlayback = true
|
||||
|
||||
playerVC.view.translatesAutoresizingMaskIntoConstraints = false
|
||||
addChild(playerVC)
|
||||
playerVC.didMove(toParent: self)
|
||||
view.addSubview(playerVC.view)
|
||||
|
||||
NSLayoutConstraint.activate([
|
||||
playerVC.view.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor),
|
||||
playerVC.view.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor),
|
||||
playerVC.view.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor),
|
||||
playerVC.view.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor),
|
||||
])
|
||||
}
|
||||
|
||||
override func viewDidAppear(_ animated: Bool) {
|
||||
|
|
|
@ -93,8 +93,8 @@ class GalleryViewController: UIPageViewController, UIPageViewControllerDataSourc
|
|||
return vc
|
||||
case .video, .audio:
|
||||
let vc = GalleryPlayerViewController()
|
||||
vc.player = AVPlayer(url: attachment.url)
|
||||
vc.delegate = avPlayerViewControllerDelegate
|
||||
vc.playerVC.player = AVPlayer(url: attachment.url)
|
||||
vc.playerVC.delegate = avPlayerViewControllerDelegate
|
||||
vc.attachment = attachment
|
||||
return vc
|
||||
case .gifv:
|
||||
|
|
Loading…
Reference in New Issue