|
@@ -80,8 +80,9 @@ class MVPlayViewController: PQBaseViewController {
|
|
PQSingletoVideoPlayer.shared.progressBloc = { [weak self] _, playProgress, duration in
|
|
PQSingletoVideoPlayer.shared.progressBloc = { [weak self] _, playProgress, duration in
|
|
(self?.collectionView.visibleCell() as? MVPlayControlViewCell)?.updateProgress(progress: playProgress / duration)
|
|
(self?.collectionView.visibleCell() as? MVPlayControlViewCell)?.updateProgress(progress: playProgress / duration)
|
|
}
|
|
}
|
|
-
|
|
|
|
PQNotification.addObserver(self, selector: #selector(didBecomeActiveNotification), name: UIApplication.didBecomeActiveNotification, object: nil)
|
|
PQNotification.addObserver(self, selector: #selector(didBecomeActiveNotification), name: UIApplication.didBecomeActiveNotification, object: nil)
|
|
|
|
+ PQNotification.addObserver(self, selector: #selector(enterBackground), name: UIApplication.didEnterBackgroundNotification, object: nil)
|
|
|
|
+ PQNotification.addObserver(self, selector: #selector(willEnterForeground), name: UIApplication.willEnterForegroundNotification, object: nil)
|
|
}
|
|
}
|
|
|
|
|
|
override func viewDidAppear(_ animated: Bool) {
|
|
override func viewDidAppear(_ animated: Bool) {
|
|
@@ -122,6 +123,7 @@ class MVPlayViewController: PQBaseViewController {
|
|
|
|
|
|
deinit {
|
|
deinit {
|
|
PQNotification.removeObserver(self)
|
|
PQNotification.removeObserver(self)
|
|
|
|
+ PQSingletoVideoPlayer.shared.stopPlayer()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -245,4 +247,22 @@ extension MVPlayViewController: UICollectionViewDelegate, UICollectionViewDataSo
|
|
collectionView.reloadData()
|
|
collectionView.reloadData()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @objc func enterBackground() {
|
|
|
|
+ BFLog(message: "进入到后台")
|
|
|
|
+ let navVc: UINavigationController? = (UIApplication.shared.keyWindow?.rootViewController) as? UINavigationController
|
|
|
|
+ if navVc?.visibleViewController is MVPlayViewController {
|
|
|
|
+ (collectionView.visibleCell() as? MVPlayControlViewCell)?.pauseBtn.isSelected = true
|
|
|
|
+ PQSingletoVideoPlayer.shared.stopPlayer(isRemove:false)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @objc func willEnterForeground() {
|
|
|
|
+ BFLog(message: "进入到前台")
|
|
|
|
+ let navVc: UINavigationController? = (UIApplication.shared.keyWindow?.rootViewController) as? UINavigationController
|
|
|
|
+ if navVc?.visibleViewController is MVPlayViewController {
|
|
|
|
+ (collectionView.visibleCell() as? MVPlayControlViewCell)?.pauseBtn.isSelected = false
|
|
|
|
+ PQSingletoVideoPlayer.shared.startPlayr()
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|