I am loading a AVPlayerViewController in my UITableViewCell and it works good but I am trying that when a cell is visible play video and when a cell is not visible pause video.
The problem is that the video load programmatically in the cell and when the cell disappears and reappears this loads the video again so it always start from the beginning. For example: if I press play the video and paused in the 10 seconds, then scroll to leave the video cell not visible and after i return to the video cell, it is loaded again and it gives the video in 0 seconds.
I use the function func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
for load video in my cell with the follow code:
let videoURL = NSURL(string: "url_video")
let player = AVPlayer(URL: videoURL!)
cell.av.player = player
cell.av.view.frame = cell.bounds
self.addChildViewController(cell.av)
cell.contentView.addSubview(cell.av.view)
cell.av.didMoveToParentViewController(self)
cell.av.view.translatesAutoresizingMaskIntoConstraints = false
I need the video remains paused, how can i do?