Я нашел несколько способов получить миниатюру для видео, используя AVAsset
Однако я хочу получить миниатюры для массива видео.Я заполняю массив из папки документов приложений на iPad.Вот как я получаю массив:
func listVideoFiles(){
let documentDirectoryPath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first!
let videoFolderPath = documentDirectoryPath.appending("/Videos")
let videoFiles = FileManager.default.enumerator(atPath: videoFolderPath)
while let file = videoFiles?.nextObject() {
videoArray.append("\(file)")
print("")
}
if videoFiles == nil {
videoArray.append("No Videos Found")
print("No Files")
}
}
Я отображаю массив в collectionView
следующим образом:
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cellA = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) as! VideoViewCell
cellA.VideoCellLabel.text = videoArray[indexPath.item]
gradientLayer = CAGradientLayer()
gradientLayer.frame = cellA.contentView.bounds
gradientLayer.colors = [#colorLiteral(red: 0.5137254902, green: 0.3764705882, blue: 0.7647058824, alpha: 1).cgColor, #colorLiteral(red: 0.1803921569, green: 0.7490196078, blue: 0.568627451, alpha: 1).cgColor]
cellA.contentView.layer.insertSublayer(gradientLayer, at: 0)
return cellA
}
Как бы получить миниатюру для каждого видео и отображенияэто в соответствующей ячейке?