Rameez
Rameez

Reputation: 322

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()

Upvotes: 1

Views: 1436

Answers (1)

Rameez
Rameez

Reputation: 322

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

playerController?.showsPlaybackControls = false

Upvotes: 1

Related Questions