1

IOS 13 bringed UIWindowScene. In my app i use next code to play the video:

let playerVC = AVPlayerViewController()
let asset = AVURLAsset(url: videoURL)
let item = AVPlayerItem(asset: asset)
playerVC.player = AVPlayer(playerItem: item)
playerVC.showsPlaybackControls = true
targetViewController.present(playerVC, animated: true) {
     playerVC.player?.play()
}

The problem occure if i lock the app orientation to portrait. In view controller:

override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
    return .portrait
}

Then i present AVPlayerViewController. After video starts i rotate the device so that video played in landscape mode. Then i press cross and AVPlayerViewController dismissed. The controller under him stay in landscape mode and not rotating back. shouldAutorotate must be false in my case. When i do a view debugging it shows, that the root UIWindowScene starts being in landscape mode. I didn't find any API to forse rotate it. In ios 12 and earlier all work just fine.

Nike Kov
  • 12,630
  • 8
  • 75
  • 122
  • "shouldAutorotate must be false" Why? If you are not willing to rotate, how do you expect to get back from landscape to portrait? – matt Oct 21 '19 at 14:22
  • @matt shouldAutorotate must be false because it cause a unity crash. I have a rare case, when unity app is acting with the regular app. It was kind of pain to make them run properly together. In ios 12 `supportedInterfaceOrientations` did the job, but in ios 13 this mechanism broken. However, i think, to set `shouldAutorotate` == true is the only way to make it work. @matt, post the answer with shouldAutorotate, i'll accept it. – Nike Kov Oct 22 '19 at 07:05

0 Answers0