我可以在tableViewcell上播放视频,但是我不知道最佳做法。 我在tableview单元上创建avplayer视图控制器。通话时播放视频(tableView:cellForRowAt:indexPath :),但效果不佳。
class NewsfeedVideoCollectionViewCell: UICollectionViewCell, Reusable, NibLoadable {
var playerVC: AVPlayerViewController?
override init(frame: CGRect) {
super.init(frame: frame)
let url = URL(string: "https://bitdash-a.akamaihd.net/content/sintel/hls/playlist.m3u8")!
player = AVPlayer()
playerVC = AVPlayerViewController()
playerVC!.player = player
contentView.addSubview(playerVC!.view)
playerVC!.view.frame = contentView.bounds
}
答案 0 :(得分:1)
我认为您应该这样做:
当细胞从可见空间移出时停止播放
在任何情况下都要为重新使用做准备以进行新的重复使用
所有取决于您的要求。每个单元格中的恕我直言AVPlayer
都不是好主意,这与使用大量内存以及开始/暂停/停止处理有关。