|
@@ -50,7 +50,7 @@ class MVHomeController: MVBaseController {
|
|
|
}()
|
|
|
|
|
|
// 标签分类
|
|
|
- lazy var collectionView: UICollectionView = {
|
|
|
+ lazy var categoryCollectionView: UICollectionView = {
|
|
|
let flowLayout = UICollectionViewFlowLayout()
|
|
|
flowLayout.sectionInset = UIEdgeInsets.zero
|
|
|
flowLayout.minimumLineSpacing = 0
|
|
@@ -99,7 +99,7 @@ class MVHomeController: MVBaseController {
|
|
|
|
|
|
self?.mVideos = hotVideos
|
|
|
|
|
|
- self?.collectionView.reloadData()
|
|
|
+ self?.categoryCollectionView.reloadData()
|
|
|
if (self?.mVideos.count ?? 0) > 0 {
|
|
|
self?.mVideos[0].isSelected = true
|
|
|
for hotModel in self!.mVideos {
|
|
@@ -111,6 +111,11 @@ class MVHomeController: MVBaseController {
|
|
|
}
|
|
|
|
|
|
self?.banner.reloadData()
|
|
|
+
|
|
|
+ //自动播放第一个视频 确保 reloaddata 完成
|
|
|
+ DispatchQueue.main.async {
|
|
|
+ self?.playVideo(page: 0)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -120,7 +125,7 @@ class MVHomeController: MVBaseController {
|
|
|
view.addSubview(stuckPointBtn)
|
|
|
view.addSubview(settingBtn)
|
|
|
view.addSubview(banner)
|
|
|
- view.addSubview(collectionView)
|
|
|
+ view.addSubview(categoryCollectionView)
|
|
|
banner.dataSource = self
|
|
|
banner.delegate = self
|
|
|
banner.isShowPageControl = false
|
|
@@ -194,12 +199,12 @@ class MVHomeController: MVBaseController {
|
|
|
|
|
|
banner.snp.remakeConstraints { make in
|
|
|
make.width.equalTo(cScreenWidth)
|
|
|
- make.height.equalTo(cScreenHeigth - 120 - collectionView.frame.maxY - 24 - 24 - cSafeAreaHeight)
|
|
|
+ make.height.equalTo(cScreenHeigth - 120 - categoryCollectionView.frame.maxY - 24 - 24 - cSafeAreaHeight)
|
|
|
make.left.equalToSuperview().offset(0)
|
|
|
make.bottom.equalToSuperview().offset(-136)
|
|
|
}
|
|
|
|
|
|
- collectionView.snp.remakeConstraints { make in
|
|
|
+ categoryCollectionView.snp.remakeConstraints { make in
|
|
|
make.width.equalTo(cScreenWidth)
|
|
|
make.height.equalTo(35)
|
|
|
make.left.equalToSuperview().offset(0)
|
|
@@ -309,9 +314,7 @@ extension MVHomeController: MVBannerDataSource, MVBannerDelegate {
|
|
|
changePlayerStatus(indexPath: indexPath)
|
|
|
}
|
|
|
|
|
|
- func pageControl(currentPage page: Int) {
|
|
|
- BFLog(message: "page is \(page)")
|
|
|
-
|
|
|
+ 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" {
|
|
@@ -326,11 +329,17 @@ extension MVHomeController: MVBannerDataSource, MVBannerDelegate {
|
|
|
}
|
|
|
|
|
|
mVideos[(hotVides?.categoryId ?? 0) - 1].isSelected = true
|
|
|
- collectionView.reloadData()
|
|
|
+ categoryCollectionView.reloadData()
|
|
|
|
|
|
lastBnnerSelectIndex = IndexPath(row: page, section: 0)
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ func pageControl(currentPage page: Int) {
|
|
|
+ BFLog(message: "page is \(page)")
|
|
|
+ playVideo(page: page)
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// MARK: - 划动分类相关代理
|
|
@@ -362,7 +371,7 @@ extension MVHomeController: UICollectionViewDelegate, UICollectionViewDataSource
|
|
|
|
|
|
let itemDataNew: MVHotVideoModel = mVideos[indexPath.item]
|
|
|
itemDataNew.isSelected = true
|
|
|
- collectionView.reloadData()
|
|
|
+ categoryCollectionView.reloadData()
|
|
|
|
|
|
// 找出当前选择分类之前的视频数量和
|
|
|
var videosCount: Int = 0
|