我正在使用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()
答案 0 :(得分:0)
最后弄清楚了这个问题!!! 在iOS 12中,如果您禁用AVPlayerController的 PlayBackControls ,则AVPlayer仍会使用轻击手势。
playerController?.showsPlaybackControls = false