2022-05-19 07:29:25 -06:00
|
|
|
import AVKit
|
|
|
|
|
|
|
|
class RCTVideoPlayerViewController: AVPlayerViewController {
|
2023-07-06 01:52:33 -06:00
|
|
|
weak var rctDelegate: RCTVideoPlayerViewControllerDelegate?
|
2023-08-12 04:18:47 -06:00
|
|
|
|
2022-05-19 07:29:25 -06:00
|
|
|
// Optional paramters
|
2023-12-07 00:47:40 -07:00
|
|
|
var preferredOrientation: String?
|
|
|
|
var autorotate: Bool?
|
2023-08-12 04:18:47 -06:00
|
|
|
|
2022-05-19 07:29:25 -06:00
|
|
|
func shouldAutorotate() -> Bool {
|
|
|
|
if autorotate! || preferredOrientation == nil || (preferredOrientation!.lowercased() == "all") {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
override func viewDidDisappear(_ animated: Bool) {
|
|
|
|
super.viewDidDisappear(animated)
|
2023-08-12 04:18:47 -06:00
|
|
|
|
2023-07-06 01:52:33 -06:00
|
|
|
rctDelegate?.videoPlayerViewControllerWillDismiss(playerViewController: self)
|
|
|
|
rctDelegate?.videoPlayerViewControllerDidDismiss(playerViewController: self)
|
2022-05-19 07:29:25 -06:00
|
|
|
}
|
|
|
|
|
2023-08-12 04:18:47 -06:00
|
|
|
#if !os(tvOS)
|
2022-05-19 07:29:25 -06:00
|
|
|
|
2023-12-07 00:47:40 -07:00
|
|
|
func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
|
|
|
|
return .all
|
|
|
|
}
|
2022-05-19 07:29:25 -06:00
|
|
|
|
2023-12-07 00:47:40 -07:00
|
|
|
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
|
|
|
|
}
|
2022-05-19 07:29:25 -06:00
|
|
|
}
|
2023-12-07 00:47:40 -07:00
|
|
|
|
2022-05-19 07:29:25 -06:00
|
|
|
#endif
|
|
|
|
}
|