When the cell is tapped if there is a video, I want to show only the video (in a avPlayerViewController), if there is no video it performs a segue to a detail vieww
I have tried this:
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
let post = postArray[indexPath.item]
let controller = PostDetailViewController.fromStoryboard(post: post)
self.navigationController?.pushViewController(controller, animated: true)
guard let videoURL = URL(string: post.videoLink) else {
return
}
let avPlayer = AVPlayer(url: videoURL)
let avController = AVPlayerViewController()
avController.player = avPlayer
present(avController, animated: true) {
avPlayer.play()
}
}
It plays the video if there is one (from Firebase), but it also opens the detail view. So I wanted the cell to open only the video or only the detailview