iOS 12的AVPlayerViewController问题

时间:2018-09-27 12:45:33

标签: ios swift avplayer avplayerviewcontroller ios12

我正在使用AVPlayerViewController播放视频,它可以在iOS 11上正常运行,但是相同的代码在iOS 12中不起作用。有人可以帮我解决此问题吗?

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

1 个答案:

答案 0 :(得分:0)

最后弄清楚了这个问题!!! 在iOS 12中,如果您禁用AVPlayerController的 PlayBackControls ,则AVPlayer仍会使用轻击手势。

playerController?.showsPlaybackControls = false