iOS 12 的 AVPlayerViewController 问题
AVPlayerViewController issue with iOS 12
我正在使用 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()
终于找到问题了!!!
在 iOS 12 中,如果您禁用 AVPlayerController 的 PlayBackControls,AVPlayer 仍会使用点击手势。
playerController?.showsPlaybackControls = false
我正在使用 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()
终于找到问题了!!! 在 iOS 12 中,如果您禁用 AVPlayerController 的 PlayBackControls,AVPlayer 仍会使用点击手势。
playerController?.showsPlaybackControls = false