|
@@ -56,6 +56,34 @@ class MVPlayViewController: PQBaseViewController {
|
|
if currentIndex != nil, itemsList.count > (currentIndex?.item ?? 0) {
|
|
if currentIndex != nil, itemsList.count > (currentIndex?.item ?? 0) {
|
|
collectionView.contentOffset = CGPoint(x: 0, y: CGFloat(currentIndex?.item ?? 0) * view.frame.size.height)
|
|
collectionView.contentOffset = CGPoint(x: 0, y: CGFloat(currentIndex?.item ?? 0) * view.frame.size.height)
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ PQSingletoVideoPlayer.shared.playStatusBloc = { [weak self] status in
|
|
|
|
+ if status == .PQVIDEO_PLAY_STATUS_END {
|
|
|
|
+ if ((self?.currentIndex?.item ?? 0) + 1) < (self?.itemsList.count ?? 0) {
|
|
|
|
+ // self?.collectionView.scrollToItem(at: IndexPath(item: (self?.currentIndex?.item ?? 0) + 1, section: 0), at: .top, animated: false)
|
|
|
|
+ self?.collectionView.contentOffset = CGPoint(x: 0, y: CGFloat((self?.currentIndex?.item ?? 0) + 1) * (self!.collectionView.frame.height))
|
|
|
|
+ DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.2) { [weak self] in
|
|
|
|
+ self?.scrollViewDidEndDecelerating(self!.collectionView)
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ (self?.collectionView.visibleCell() as? MVPlayControlViewCell)?.tagClick()
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ PQSingletoVideoPlayer.shared.progressBloc = { [weak self] _, playProgress, duration in
|
|
|
|
+ (self?.collectionView.visibleCell() as? MVPlayControlViewCell)?.updateProgress(progress: playProgress / duration)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override func viewDidAppear(_ animated: Bool) {
|
|
|
|
+ super.viewDidAppear(animated)
|
|
|
|
+ PQSingletoVideoPlayer.shared.resumePlayer()
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override func viewDidDisappear(_ animated: Bool) {
|
|
|
|
+ super.viewDidDisappear(animated)
|
|
|
|
+ PQSingletoVideoPlayer.shared.pausePlayer()
|
|
}
|
|
}
|
|
|
|
|
|
/// 请求网络数据
|
|
/// 请求网络数据
|
|
@@ -75,6 +103,7 @@ class MVPlayViewController: PQBaseViewController {
|
|
self?.itemsList = self!.itemsList + videoList!
|
|
self?.itemsList = self!.itemsList + videoList!
|
|
}
|
|
}
|
|
self?.collectionView.reloadData()
|
|
self?.collectionView.reloadData()
|
|
|
|
+ self?.scrollViewDidEndDecelerating(self!.collectionView)
|
|
} else {
|
|
} else {
|
|
self?.pageNum = (self?.pageNum ?? 1) - 1
|
|
self?.pageNum = (self?.pageNum ?? 1) - 1
|
|
}
|
|
}
|
|
@@ -84,7 +113,7 @@ class MVPlayViewController: PQBaseViewController {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-extension MVPlayViewController: UICollectionViewDelegate, UICollectionViewDataSource {
|
|
|
|
|
|
+extension MVPlayViewController: UICollectionViewDelegate, UICollectionViewDataSource, UIScrollViewDelegate {
|
|
func collectionView(_: UICollectionView, numberOfItemsInSection _: Int) -> Int {
|
|
func collectionView(_: UICollectionView, numberOfItemsInSection _: Int) -> Int {
|
|
return itemsList.count
|
|
return itemsList.count
|
|
}
|
|
}
|
|
@@ -101,6 +130,25 @@ extension MVPlayViewController: UICollectionViewDelegate, UICollectionViewDataSo
|
|
|
|
|
|
func collectionView(_: UICollectionView, didSelectItemAt _: IndexPath) {}
|
|
func collectionView(_: UICollectionView, didSelectItemAt _: IndexPath) {}
|
|
|
|
|
|
|
|
+ func scrollViewDidEndDecelerating(_: UIScrollView) {
|
|
|
|
+ if itemsList.count <= 0 {
|
|
|
|
+ PQSingletoVideoPlayer.shared.stopPlayer()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ let cell: MVPlayControlViewCell? = collectionView.visibleCell() as? MVPlayControlViewCell
|
|
|
|
+ if cell == nil {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ let indexPath = collectionView.indexPath(for: cell!)
|
|
|
|
+ if currentIndex != nil, currentIndex?.item == indexPath?.item {
|
|
|
|
+ PQSingletoVideoPlayer.shared.resumePlayer()
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ currentIndex = indexPath
|
|
|
|
+ PQSingletoVideoPlayer.shared.configPlyer(videoData: itemsList[indexPath?.item ?? 0], controllerView: cell!.coverImageView)
|
|
|
|
+ PQSingletoVideoPlayer.shared.startPlayr()
|
|
|
|
+ }
|
|
|
|
+
|
|
/// 按钮点击处理
|
|
/// 按钮点击处理
|
|
/// - Parameters:
|
|
/// - Parameters:
|
|
/// - sender: <#sender description#>
|
|
/// - sender: <#sender description#>
|
|
@@ -109,8 +157,11 @@ extension MVPlayViewController: UICollectionViewDelegate, UICollectionViewDataSo
|
|
func btnClickHandle(sender: UIButton, videoData: PQVideoListModel?) {
|
|
func btnClickHandle(sender: UIButton, videoData: PQVideoListModel?) {
|
|
switch sender.tag {
|
|
switch sender.tag {
|
|
case 1: // 暂停/播放
|
|
case 1: // 暂停/播放
|
|
-
|
|
|
|
- break
|
|
|
|
|
|
+ if sender.isSelected {
|
|
|
|
+ PQSingletoVideoPlayer.shared.pausePlayer()
|
|
|
|
+ } else {
|
|
|
|
+ PQSingletoVideoPlayer.shared.resumePlayer()
|
|
|
|
+ }
|
|
case 2: // 昵称
|
|
case 2: // 昵称
|
|
|
|
|
|
break
|
|
break
|