Done button click event in AVPlayerViewController

前端 未结 9 864
广开言路
广开言路 2020-12-03 17:40

I want to play local video in AVPlayerViewController but did not find click event of Done button.

My video is able to play in AVPlayerViewController but I did not fi

9条回答
  •  借酒劲吻你
    2020-12-03 17:54

    I guess there are lots of ways to skin a cat. I needed to handle the 'Done' click event. In my case, I wanted to make sure I was able to hook into the event after the "X" was clicked and the AVPlayerViewController was COMPLETELY closed (dismissed).

    Swift 4.0

    protocol TableViewCellVideoPlayerViewControllerDelegate: class {
        func viewControllerDismissed()
    }
    
    class MyPlayerViewController: AVPlayerViewController {
    
        weak var navDelegate: TableViewCellVideoPlayerViewControllerDelegate?
    
        open override func viewDidDisappear(_ animated: Bool) {
            super.viewWillDisappear(animated)
            if self.isBeingDismissed {
                self.navDelegate?.viewControllerDismissed()
            }
        }
    }
    
    class TodayCell: UITableViewCell, SFSafariViewControllerDelegate,  TableViewCellVideoPlayerViewControllerDelegate {
        func viewControllerDismissed() {
            self.continueJourney()
        }
     }
    

提交回复
热议问题