UICollectionView에 표시된 일부 비디오가 있습니다. 사용자가 UICollectionView를 스크롤 할 때 비디오가로드되지 않고 디버그에 올바른 mp4 URL이 표시되는 경우에도 모든 셀이 회색으로 표시되고 올바른 비디오로 채워지지 않습니다.UICollectionView 내부의 비디오 : 스크롤 문제
func collectionView(cv: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let videoCell = collectionView!.dequeueReusableCellWithReuseIdentifier("VideoCell", forIndexPath: indexPath) as? UICollectionViewCell
var aPlayer = AVPlayer()
let moviePlayerController = AVPlayerViewController()
let item = self.wall[indexPath.row]
print("URL:"+item.video_link)
let fileUrl = NSURL(string: item.video_link)
dispatch_async(dispatch_get_main_queue(), {
aPlayer = AVPlayer(URL: fileUrl!)
moviePlayerController.player = aPlayer
moviePlayerController.view.frame = CGRectMake(0, 0, videoCell!.frame.size.width, videoCell!.frame.size.height)
moviePlayerController.videoGravity = AVLayerVideoGravityResizeAspectFill
moviePlayerController.view.sizeToFit()
moviePlayerController.player?.actionAtItemEnd=AVPlayerActionAtItemEnd.None
NSNotificationCenter.defaultCenter().addObserver(self,
selector: "playerItemDidReachEnd:",
name: AVPlayerItemDidPlayToEndTimeNotification,
object: moviePlayerController.player!.currentItem)
moviePlayerController.showsPlaybackControls = false
moviePlayerController.player?.play()
/*
videoCell?.layer.shouldRasterize = true;
videoCell!.layer.rasterizationScale = UIScreen.mainScreen().scale;
*/
videoCell!.addSubview(moviePlayerController.view)
})
return videoCell!
}
사람이 나에게 문제를 이해하는 데 도움이 될 수 있습니다 : 여기
코드인가?
해결책을 찾았습니까? –