我试图在scrollView中播放视频。就此而言,我最终使用了AVPlayerViewController,因为它与多个视频之间的间距非常有效。但问题是,所有视频都是近似的。比屏幕大小大1/3。我做错了什么?
let player = AVPlayer(URL: NSURL(string: videoLink))
let playerController = AVPlayerViewController()
playerController.player = player
playerController.showsPlaybackControls = false
playerController.videoGravity = AVLayerVideoGravityResizeAspect
playerController.view.frame = CGRectMake(0, (UIScreen.mainScreen().bounds.height) * CGFloat(index), UIScreen.mainScreen().bounds.width,0)
更新
以下代码仍会显示视频。框架非常小,但仍然显示。我尝试通过打印出" view.frame.bounds.width"," view.frame.bounds.size.width"," view.frame.size来调试它。 width"和" view.frame.width"他们都说" 0"
playerController.view.frame = CGRectMake(0, (self.view.frame.size.height - 64) * CGFloat(index) + 30, 0, 0)