800aee09de
* chore: format swift code * chore: format clang code * chore: format kotlin code * refactor: rename folder "API" to "api"
45 lines
1.3 KiB
Swift
45 lines
1.3 KiB
Swift
import AVKit
|
|
|
|
class RCTVideoPlayerViewController: AVPlayerViewController {
|
|
weak 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)
|
|
|
|
rctDelegate?.videoPlayerViewControllerWillDismiss(playerViewController: self)
|
|
rctDelegate?.videoPlayerViewControllerDidDismiss(playerViewController: self)
|
|
}
|
|
|
|
#if !os(tvOS)
|
|
|
|
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
|
|
}
|