let scale = UIScreen.main.bounds.width / CGFloat((videoinfo.Width as NSString).floatValue)
let bestHeight = CGFloat((videoinfo.Height as NSString).floatValue) * scale
cell.videoViewHeight.constant = bestHeight
cell.videoView.frame.size.height = bestHeight
let playerItem = AVPlayerItem(url: URL(string:videoinfo.Filename)!)
cell.player = AVQueuePlayer(playerItem: playerItem)
cell.looper = AVPlayerLooper(player: cell.player!, templateItem: playerItem)
var layer = AVPlayerLayer()
layer = AVPlayerLayer(player: cell.player)
layer.backgroundColor = UIColor.white.cgColor
layer.frame = cell.videoView.bounds
layer.videoGravity = .resizeAspectFill
cell.videoView.layer.sublayers?
.filter { $0 is AVPlayerLayer }
.forEach { $0.removeFromSuperlayer() }
cell.videoView.layer.addSublayer(layer)
cell.player?.play()
正在Tableview单元中播放视频的代码。
请检查视频
https://drive.google.com/open?id=1Vlc21H5UpacUR0V2dhvO-pGAlEMNr8ls
您可以看到,AVPlayer滚动时会奇怪地出现白色边框。
知道是什么原因造成的?