单击关闭按钮时,AVPlayerController不关闭

时间:2018-10-27 14:35:05

标签: swift xcode swift4 ios12

i自定义AVPlayerViewController通过创建类LandscapeAVPlayerController继承类AVPlayerViewController来处理玩家方向。

然后我使用LandscapeAVPlayerController播放一些流视频网址,如下所示:

let videoURL = URL(string: tmpStrURL)
let player = AVPlayer(url: videoURL!)
let playerViewController = LandscapeAVPlayerController()
playerViewController.player = player
playerViewController.modalPresentationStyle =  UIModalPresentationStyle.fullScreen
this.present(playerViewController, animated: true) {
                                            playerViewController.player!.play()
                                        }

LandscapeAVPlayerController类

import AVKit

class LandscapeAVPlayerController: AVPlayerViewController {

override var supportedInterfaceOrientations: UIInterfaceOrientationMask 
{
    return .landscape
}

override var shouldAutorotate: Bool {
    return true
}
override func viewWillDisappear(_ animated: Bool) {
    super.viewWillDisappear(animated)
    AppDelegate.AppUtility.lockOrientation(.portrait)
}

}

它可以与旧的ios版本完美配合。但是最近,有几台设备更新到ios 12,并且单击关闭按钮时播放器控制器无法关闭。它仅在ios 12上发生。

我尝试使用AVPlayerViewController用户,但得到相同的结果。

0 个答案:

没有答案