Stopping/Pausing 在表格视图单元格中创建的 avplayer class
Stopping/Pausing avplayer created in tableview cell class
我正在使用 tableview 开发视频源应用程序。
我在 tableview 单元格子类中创建 AVPlayer
对象,并在 cellforitem 中将播放项分配给它。一切正常。
我的问题是我想在 viewDidDisappear
上停止视频,但我无法访问 tableview 单元格子类的 AvPlayer 对象来停止它。
有什么想法吗?
你可以试试
tableView.visibleCells.forEach {
if let cell = [=10=] as? PostsWithVideoCustom , let player = cell.player { // assuming it's optional
// stop it here
}
}
我正在使用 tableview 开发视频源应用程序。
我在 tableview 单元格子类中创建 AVPlayer
对象,并在 cellforitem 中将播放项分配给它。一切正常。
我的问题是我想在 viewDidDisappear
上停止视频,但我无法访问 tableview 单元格子类的 AvPlayer 对象来停止它。
有什么想法吗?
你可以试试
tableView.visibleCells.forEach {
if let cell = [=10=] as? PostsWithVideoCustom , let player = cell.player { // assuming it's optional
// stop it here
}
}