store video orientation & revert on closing player.

This commit is contained in:
Aiden Vigue 2021-06-28 11:25:38 -04:00
parent e392a03d05
commit 2919b25a5d
No known key found for this signature in database
GPG Key ID: B9A09843AB079D5B
2 changed files with 6 additions and 0 deletions

View File

@ -56,6 +56,7 @@ struct ItemView: View {
.navigationBarHidden(false)
.navigationBarBackButtonHidden(false)
.environmentObject(videoPlayerItem)
.supportedOrientations(.all)
}
}
}

View File

@ -81,6 +81,7 @@ class PlayerViewController: UIViewController, GCKDiscoveryManagerListener, GCKRe
var playbackItem = PlaybackItem()
var remoteTimeUpdateTimer: Timer?
var upNextViewModel: UpNextViewModel = UpNextViewModel()
var lastOri: UIDeviceOrientation!
// MARK: IBActions
@IBAction func seekSliderStart(_ sender: Any) {
@ -390,6 +391,8 @@ class PlayerViewController: UIViewController, GCKDiscoveryManagerListener, GCKRe
setupNextUpView()
upNextViewModel.delegate = self
}
lastOri = UIDevice.current.orientation
if !UIDevice.current.orientation.isLandscape || UIDevice.current.orientation.isFlat {
let value = UIInterfaceOrientation.landscapeRight.rawValue
@ -434,6 +437,8 @@ class PlayerViewController: UIViewController, GCKDiscoveryManagerListener, GCKRe
self.tabBarController?.tabBar.isHidden = false
self.navigationController?.isNavigationBarHidden = false
overrideUserInterfaceStyle = .unspecified
UIDevice.current.setValue(lastOri.rawValue, forKey: "orientation")
UIViewController.attemptRotationToDeviceOrientation()
super.viewWillDisappear(animated)
}