UIWindowScene AVPlayerViewController orientation issue ios 13

313 views Asked by At

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.

0

There are 0 answers