简体   繁体   中英

AVPlayerViewController issue with iOS 12

I'm using AVPlayerViewController for playing video it works fine with iOS 11 but the same code doesn't work in iOS 12. could anyone help me to fix this issue please?

 let url: URL = Bundle.main.url(forResource: "sampleVideo", withExtension: ".mp4")!

    let avAsset = AVURLAsset(url: url)
    let playerItem = AVPlayerItem(asset: avAsset)
    player = AVPlayer(playerItem: playerItem)
    playerController = AVPlayerViewController()
    playerController?.player = player
    playerController?.view.frame = videoHolderView?.bounds ?? CGRect.zero

    guard let videoView = playerController?.view else { return }
    videoView.tag = 101
    videoHolderView.addSubview(videoView)
    player?.play()

Finally figured out the issue!!! in iOS 12 if you disable PlayBackControls of AVPlayerController, AVPlayer will still consume the tap gesture.

playerController?.showsPlaybackControls = false

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM