2022-05-19 07:29:25 -06:00
|
|
|
import AVKit
|
|
|
|
|
|
|
|
class RCTVideoPlayerViewController: AVPlayerViewController {
|
|
|
|
|
|
|
|
var rctDelegate:RCTVideoPlayerViewControllerDelegate!
|
|
|
|
|
|
|
|
// Optional paramters
|
|
|
|
var preferredOrientation:String?
|
|
|
|
var autorotate:Bool?
|
|
|
|
|
|
|
|
func shouldAutorotate() -> Bool {
|
|
|
|
|
|
|
|
if autorotate! || preferredOrientation == nil || (preferredOrientation!.lowercased() == "all") {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
override func viewDidDisappear(_ animated: Bool) {
|
|
|
|
super.viewDidDisappear(animated)
|
2022-08-04 19:53:22 -06:00
|
|
|
|
|
|
|
if rctDelegate != nil {
|
|
|
|
rctDelegate.videoPlayerViewControllerWillDismiss(playerViewController: self)
|
|
|
|
rctDelegate.videoPlayerViewControllerDidDismiss(playerViewController: self)
|
|
|
|
}
|
2022-05-19 07:29:25 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
#if !TARGET_OS_TV
|
|
|
|
|
|
|
|
func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
|
|
|
|
return .all
|
|
|
|
}
|
|
|
|
|
|
|
|
func preferredInterfaceOrientationForPresentation() -> UIInterfaceOrientation {
|
|
|
|
if preferredOrientation?.lowercased() == "landscape" {
|
|
|
|
return .landscapeRight
|
|
|
|
} else if preferredOrientation?.lowercased() == "portrait" {
|
|
|
|
return .portrait
|
|
|
|
} else {
|
|
|
|
// default case
|
|
|
|
let orientation = UIApplication.shared.statusBarOrientation
|
|
|
|
return orientation
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|