|
@@ -7,12 +7,13 @@
|
|
|
|
|
|
import BFFramework
|
|
import BFFramework
|
|
class MVHomeController: MVBaseController {
|
|
class MVHomeController: MVBaseController {
|
|
- private var banner: MVBanner = {
|
|
|
|
- let banner = MVBanner(frame: .zero, margin: 30, lineSpacing: 12, minScale: MVBanner.Scale(scale: 1))
|
|
|
|
- banner.backgroundColor = UIColor.white
|
|
|
|
|
|
+ //视频播放列表
|
|
|
|
+ private var viewListView: MVBanner = {
|
|
|
|
+ let videoListView = MVBanner(frame: .zero, margin: 30, lineSpacing: 12, minScale: MVBanner.Scale(scale: 1))
|
|
|
|
+ videoListView.backgroundColor = UIColor.white
|
|
|
|
|
|
- banner.register(classCellType: MVBannerCell.self)
|
|
|
|
- return banner
|
|
|
|
|
|
+ videoListView.register(classCellType: MVBannerCell.self)
|
|
|
|
+ return videoListView
|
|
}()
|
|
}()
|
|
|
|
|
|
// 卡点视频 btn
|
|
// 卡点视频 btn
|
|
@@ -102,7 +103,7 @@ class MVHomeController: MVBaseController {
|
|
super.viewWillDisappear(animated)
|
|
super.viewWillDisappear(animated)
|
|
|
|
|
|
// 停止播放
|
|
// 停止播放
|
|
- let cell: MVBannerCell? = banner.collectionView.cellForItem(at: lastBnnerSelectIndex) as? MVBannerCell
|
|
|
|
|
|
+ let cell: MVBannerCell? = viewListView.collectionView.cellForItem(at: lastBnnerSelectIndex) as? MVBannerCell
|
|
cell?.pauseView.isHidden = false
|
|
cell?.pauseView.isHidden = false
|
|
PQSingletoVideoPlayer.shared.stopPlayer(isRemove: false)
|
|
PQSingletoVideoPlayer.shared.stopPlayer(isRemove: false)
|
|
}
|
|
}
|
|
@@ -129,12 +130,12 @@ class MVHomeController: MVBaseController {
|
|
BFLog(message: " self?.mAllVideos count is \(String(describing: self?.mAllVideos.count))")
|
|
BFLog(message: " self?.mAllVideos count is \(String(describing: self?.mAllVideos.count))")
|
|
}
|
|
}
|
|
|
|
|
|
- self?.banner.reloadData()
|
|
|
|
|
|
+ self?.viewListView.reloadData()
|
|
|
|
|
|
//自动播放第一个视频 确保 reloaddata 完成
|
|
//自动播放第一个视频 确保 reloaddata 完成
|
|
- DispatchQueue.main.async {
|
|
|
|
|
|
+
|
|
self?.playVideo(page: 0)
|
|
self?.playVideo(page: 0)
|
|
- }
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -147,12 +148,12 @@ class MVHomeController: MVBaseController {
|
|
// view.addSubview(mineBtn)
|
|
// view.addSubview(mineBtn)
|
|
view.addSubview(stuckPointBtn)
|
|
view.addSubview(stuckPointBtn)
|
|
view.addSubview(settingBtn)
|
|
view.addSubview(settingBtn)
|
|
- view.addSubview(banner)
|
|
|
|
|
|
+ view.addSubview(viewListView)
|
|
view.addSubview(categoryCollectionView)
|
|
view.addSubview(categoryCollectionView)
|
|
- banner.dataSource = self
|
|
|
|
- banner.delegate = self
|
|
|
|
- banner.isShowPageControl = false
|
|
|
|
- banner.reloadData()
|
|
|
|
|
|
+ viewListView.dataSource = self
|
|
|
|
+ viewListView.delegate = self
|
|
|
|
+ viewListView.isShowPageControl = false
|
|
|
|
+ viewListView.reloadData()
|
|
|
|
|
|
addLayout()
|
|
addLayout()
|
|
|
|
|
|
@@ -167,7 +168,7 @@ class MVHomeController: MVBaseController {
|
|
PQSingletoVideoPlayer.shared.progressBloc = { [weak self] loadProgress, playProgress, duration in
|
|
PQSingletoVideoPlayer.shared.progressBloc = { [weak self] loadProgress, playProgress, duration in
|
|
|
|
|
|
BFLog(message: "loadProgress \(loadProgress) playProgress\(playProgress) \(duration)")
|
|
BFLog(message: "loadProgress \(loadProgress) playProgress\(playProgress) \(duration)")
|
|
- let cell: MVBannerCell? = self?.banner.collectionView.cellForItem(at: self?.lastBnnerSelectIndex ?? IndexPath()) as? MVBannerCell
|
|
|
|
|
|
+ let cell: MVBannerCell? = self?.viewListView.collectionView.cellForItem(at: self?.lastBnnerSelectIndex ?? IndexPath()) as? MVBannerCell
|
|
|
|
|
|
cell?.progressView.progress = playProgress / loadProgress
|
|
cell?.progressView.progress = playProgress / loadProgress
|
|
}
|
|
}
|
|
@@ -220,7 +221,7 @@ class MVHomeController: MVBaseController {
|
|
make.bottom.equalToSuperview().offset(-50)
|
|
make.bottom.equalToSuperview().offset(-50)
|
|
}
|
|
}
|
|
|
|
|
|
- banner.snp.remakeConstraints { make in
|
|
|
|
|
|
+ viewListView.snp.remakeConstraints { make in
|
|
make.width.equalTo(cScreenWidth)
|
|
make.width.equalTo(cScreenWidth)
|
|
make.height.equalTo(cScreenHeigth - 120 - categoryCollectionView.frame.maxY - 24 - 24 - cSafeAreaHeight)
|
|
make.height.equalTo(cScreenHeigth - 120 - categoryCollectionView.frame.maxY - 24 - 24 - cSafeAreaHeight)
|
|
make.left.equalToSuperview().offset(0)
|
|
make.left.equalToSuperview().offset(0)
|
|
@@ -230,7 +231,7 @@ class MVHomeController: MVBaseController {
|
|
categoryCollectionView.snp.remakeConstraints { make in
|
|
categoryCollectionView.snp.remakeConstraints { make in
|
|
make.width.equalTo(cScreenWidth)
|
|
make.width.equalTo(cScreenWidth)
|
|
make.height.equalTo(35)
|
|
make.height.equalTo(35)
|
|
- make.left.equalToSuperview().offset(0)
|
|
|
|
|
|
+ make.left.equalToSuperview().offset(11)
|
|
make.top.equalToSuperview().offset(cDevice_iPhoneStatusBarHei)
|
|
make.top.equalToSuperview().offset(cDevice_iPhoneStatusBarHei)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -285,7 +286,7 @@ class MVHomeController: MVBaseController {
|
|
BFLog(message: "userStatus is \(BFLoginUserInfo.shared.userStatus)")
|
|
BFLog(message: "userStatus is \(BFLoginUserInfo.shared.userStatus)")
|
|
if BFLoginUserInfo.shared.userStatus == "3" {
|
|
if BFLoginUserInfo.shared.userStatus == "3" {
|
|
|
|
|
|
- PQBandingPhoneRemindView.accountBlockRemindView(remindTitle:"无法进行再创作")
|
|
|
|
|
|
+ PQBandingPhoneRemindView.accountBlockRemindView(remindTitle:"无法上传视频")
|
|
return false
|
|
return false
|
|
}
|
|
}
|
|
|
|
|
|
@@ -356,7 +357,7 @@ extension MVHomeController: MVBannerDataSource, MVBannerDelegate {
|
|
}
|
|
}
|
|
|
|
|
|
func changePlayerStatus(indexPath: IndexPath) {
|
|
func changePlayerStatus(indexPath: IndexPath) {
|
|
- let cell: MVBannerCell? = banner.collectionView.cellForItem(at: indexPath) as? MVBannerCell
|
|
|
|
|
|
+ let cell: MVBannerCell? = viewListView.collectionView.cellForItem(at: indexPath) as? MVBannerCell
|
|
|
|
|
|
if PQSingletoVideoPlayer.shared.isPlaying {
|
|
if PQSingletoVideoPlayer.shared.isPlaying {
|
|
cell?.pauseView.isHidden = false
|
|
cell?.pauseView.isHidden = false
|
|
@@ -378,23 +379,30 @@ extension MVHomeController: MVBannerDataSource, MVBannerDelegate {
|
|
}
|
|
}
|
|
|
|
|
|
func playVideo(page: Int) {
|
|
func playVideo(page: Int) {
|
|
- let cell: MVBannerCell? = banner.collectionView.cellForItem(at: IndexPath(row: page, section: 0)) as? MVBannerCell
|
|
|
|
- let showProtocal: String? = getUserDefaults(key: cShowProtocal) as? String
|
|
|
|
- if mVideos.count > 0, cell != nil, showProtocal != nil, showProtocal == "1" {
|
|
|
|
- cell?.pauseView.isHidden = true
|
|
|
|
- PQSingletoVideoPlayer.shared.configPlyer(videoData: mAllVideos[page], controllerView: cell!.converView)
|
|
|
|
-
|
|
|
|
- let hotVides = mVideos.first(where: { (items) -> Bool in
|
|
|
|
- items.categoryName == mAllVideos[page].categoryName
|
|
|
|
- })
|
|
|
|
- for hot in mVideos {
|
|
|
|
- hot.isSelected = false
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
|
|
+ DispatchQueue.main.async {
|
|
|
|
+ let cell: MVBannerCell? = self.viewListView.collectionView.cellForItem(at: IndexPath(row: page, section: 0)) as? MVBannerCell
|
|
|
|
+ let showProtocal: String? = getUserDefaults(key: cShowProtocal) as? String
|
|
|
|
+ if self.mVideos.count > 0, cell != nil, showProtocal != nil, showProtocal == "1" {
|
|
|
|
+ cell?.pauseView.isHidden = true
|
|
|
|
+ PQSingletoVideoPlayer.shared.configPlyer(videoData: self.mAllVideos[page], controllerView: cell!.converView)
|
|
|
|
+
|
|
|
|
+ let hotVides = self.mVideos.first(where: { (items) -> Bool in
|
|
|
|
+ items.categoryName == self.mAllVideos[page].categoryName
|
|
|
|
+ })
|
|
|
|
+ for hot in self.mVideos {
|
|
|
|
+ hot.isSelected = false
|
|
|
|
+ }
|
|
|
|
|
|
- mVideos[(hotVides?.categoryId ?? 0) - 1].isSelected = true
|
|
|
|
- categoryCollectionView.reloadData()
|
|
|
|
|
|
+ self.mVideos[(hotVides?.categoryId ?? 0) - 1].isSelected = true
|
|
|
|
+ self.categoryCollectionView.reloadData()
|
|
|
|
|
|
- lastBnnerSelectIndex = IndexPath(row: page, section: 0)
|
|
|
|
|
|
+ self.lastBnnerSelectIndex = IndexPath(row: page, section: 0)
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }else{
|
|
|
|
+ BFLog(message: "播放不成功: cell:\(cell) mVideos:\(self.mVideos.count) showProtocal: is \(showProtocal)")
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -444,6 +452,8 @@ extension MVHomeController: UICollectionViewDelegate, UICollectionViewDataSource
|
|
}
|
|
}
|
|
BFLog(message: "indexPath 选择\(indexPath.item) 之前的视频合\(videosCount)")
|
|
BFLog(message: "indexPath 选择\(indexPath.item) 之前的视频合\(videosCount)")
|
|
}
|
|
}
|
|
- banner.scrollToItem(at: videosCount, animated: true)
|
|
|
|
|
|
+ viewListView.scrollToItem(at: videosCount, animated: false)
|
|
|
|
+
|
|
|
|
+ playVideo(page: videosCount)
|
|
}
|
|
}
|
|
}
|
|
}
|