|
@@ -50,9 +50,7 @@ class MVHomeController: MVBaseController {
|
|
settingBtn.tag = 3000
|
|
settingBtn.tag = 3000
|
|
return settingBtn
|
|
return settingBtn
|
|
}()
|
|
}()
|
|
-
|
|
|
|
- // 所有分类数据
|
|
|
|
- var itemList: [MVTagsModel] = Array<MVTagsModel>.init()
|
|
|
|
|
|
+
|
|
// 标签分类
|
|
// 标签分类
|
|
lazy var collectionView: UICollectionView = {
|
|
lazy var collectionView: UICollectionView = {
|
|
let flowLayout = UICollectionViewFlowLayout()
|
|
let flowLayout = UICollectionViewFlowLayout()
|
|
@@ -76,44 +74,72 @@ class MVHomeController: MVBaseController {
|
|
collectionView.delaysContentTouches = false
|
|
collectionView.delaysContentTouches = false
|
|
return collectionView
|
|
return collectionView
|
|
}()
|
|
}()
|
|
|
|
+
|
|
|
|
+ var mVideos:Array = Array<MVHotVideoModel>.init()
|
|
|
|
+
|
|
|
|
+ var mAllVideos:Array = Array<PQVideoListModel>.init()
|
|
|
|
|
|
override func viewDidLoad() {
|
|
override func viewDidLoad() {
|
|
super.viewDidLoad()
|
|
super.viewDidLoad()
|
|
- view.addSubview(mineBtn)
|
|
|
|
|
|
+// view.addSubview(mineBtn)
|
|
view.addSubview(stuckPointBtn)
|
|
view.addSubview(stuckPointBtn)
|
|
view.addSubview(settingBtn)
|
|
view.addSubview(settingBtn)
|
|
view.addSubview(banner)
|
|
view.addSubview(banner)
|
|
view.addSubview(collectionView)
|
|
view.addSubview(collectionView)
|
|
banner.dataSource = self
|
|
banner.dataSource = self
|
|
banner.delegate = self
|
|
banner.delegate = self
|
|
- banner.reloadData()
|
|
|
|
banner.isShowPageControl = false
|
|
banner.isShowPageControl = false
|
|
|
|
+ banner.reloadData()
|
|
|
|
|
|
addLayout()
|
|
addLayout()
|
|
-
|
|
|
|
- for i in 0 ... 10 {
|
|
|
|
- var model: MVTagsModel = MVTagsModel()
|
|
|
|
- model.tagEmoji = "https://img0.baidu.com/it/u=3433562696,4282002140&fm=26&fmt=auto&gp=0.jpg"
|
|
|
|
- model.tagName = "热门"
|
|
|
|
- if(i == 5){
|
|
|
|
- model.tagName = "我是中华人民有共和国"
|
|
|
|
|
|
+
|
|
|
|
+ MVHomeViewModel.getHomeHotVideos {[weak self] hotVideos, _ in
|
|
|
|
+ BFLog(message: "hotVideos count is :\(hotVideos.count)")
|
|
|
|
+
|
|
|
|
+ self?.mVideos = hotVideos
|
|
|
|
+
|
|
|
|
+ self?.collectionView.reloadData()
|
|
|
|
+ if((self?.mVideos.count ?? 0) > 0 ){
|
|
|
|
+
|
|
|
|
+ self?.mVideos[0].isSelected = true
|
|
|
|
+ for hotModel in self!.mVideos{
|
|
|
|
+ for video in hotModel.videos {
|
|
|
|
+ self?.mAllVideos.append(video)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ BFLog(message: " self?.mAllVideos count is \(String(describing: self?.mAllVideos.count))")
|
|
}
|
|
}
|
|
-
|
|
|
|
- itemList.append(model)
|
|
|
|
|
|
+
|
|
|
|
+ self?.banner.reloadData()
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
- MVHomeViewModel.getHomeHotVideos {[weak self] hotVideos, _ in
|
|
|
|
- BFLog(message: "hotVideos count is :\(hotVideos.count)")
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ PQSingletoVideoPlayer.shared.progressBloc = { [weak self] loadProgress, playProgress, duration in
|
|
|
|
+
|
|
|
|
+ BFLog(message: "loadProgress \(loadProgress) playProgress\(playProgress) \(duration)")
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ PQSingletoVideoPlayer.shared.playStatusBloc = { [weak self] status in
|
|
|
|
+
|
|
|
|
+ if(status == .PQVIDEO_PLAY_STATUS_END){
|
|
|
|
+ PQSingletoVideoPlayer.shared.resetPlayer()
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
|
|
func addLayout() {
|
|
func addLayout() {
|
|
- mineBtn.snp.remakeConstraints { make in
|
|
|
|
- make.width.equalTo(60)
|
|
|
|
- make.height.equalTo(60)
|
|
|
|
- make.left.equalToSuperview().offset(16)
|
|
|
|
- make.bottom.equalToSuperview().offset(-50)
|
|
|
|
- }
|
|
|
|
|
|
+// mineBtn.snp.remakeConstraints { make in
|
|
|
|
+// make.width.equalTo(60)
|
|
|
|
+// make.height.equalTo(60)
|
|
|
|
+// make.left.equalToSuperview().offset(16)
|
|
|
|
+// make.bottom.equalToSuperview().offset(-50)
|
|
|
|
+// }
|
|
stuckPointBtn.snp.remakeConstraints { make in
|
|
stuckPointBtn.snp.remakeConstraints { make in
|
|
make.width.equalTo(60)
|
|
make.width.equalTo(60)
|
|
make.height.equalTo(60)
|
|
make.height.equalTo(60)
|
|
@@ -146,7 +172,9 @@ class MVHomeController: MVBaseController {
|
|
@objc func btnClick(sender: UIButton) {
|
|
@objc func btnClick(sender: UIButton) {
|
|
// 先判断是否登录
|
|
// 先判断是否登录
|
|
if !BFLoginUserInfo.shared.isLogin() && sender.tag != 3000 {
|
|
if !BFLoginUserInfo.shared.isLogin() && sender.tag != 3000 {
|
|
- navigationController?.present(MVLoginController(), animated: true, completion: nil)
|
|
|
|
|
|
+ let vc = MVLoginController()
|
|
|
|
+ vc.modalPresentationStyle = .fullScreen
|
|
|
|
+ present(vc, animated: true, completion: nil)
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
@@ -172,19 +200,21 @@ class MVHomeController: MVBaseController {
|
|
|
|
|
|
extension MVHomeController: MVBannerDataSource, MVBannerDelegate {
|
|
extension MVHomeController: MVBannerDataSource, MVBannerDelegate {
|
|
func numberOfItems() -> Int {
|
|
func numberOfItems() -> Int {
|
|
- return 3
|
|
|
|
|
|
+ return mAllVideos.count
|
|
}
|
|
}
|
|
|
|
|
|
func banner(_ banner: MVBanner, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
|
|
func banner(_ banner: MVBanner, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
|
|
let cell: MVBannerCell = banner.dequeueReusableCell(for: indexPath)
|
|
let cell: MVBannerCell = banner.dequeueReusableCell(for: indexPath)
|
|
cell.contentView.layer.masksToBounds = true
|
|
cell.contentView.layer.masksToBounds = true
|
|
cell.contentView.layer.cornerRadius = 10
|
|
cell.contentView.layer.cornerRadius = 10
|
|
- cell.contentView.backgroundColor = UIColor.red
|
|
|
|
- cell.iconIView.image = UIImage(named: String(format: "banner%d.jpeg", indexPath.row))
|
|
|
|
|
|
+ cell.contentView.backgroundColor = UIColor.white
|
|
|
|
+
|
|
|
|
+ cell.videoData = mAllVideos[indexPath.row]
|
|
cell.reCreateBtnClicHandle = { [weak self] _, _ in
|
|
cell.reCreateBtnClicHandle = { [weak self] _, _ in
|
|
BFLog(message: "点击了创同款")
|
|
BFLog(message: "点击了创同款")
|
|
|
|
+ PQSingletoVideoPlayer.shared.stopPlayer(isRemove: false)
|
|
}
|
|
}
|
|
-// cell.typeLabe.text = String(indexPath.row)
|
|
|
|
|
|
+
|
|
|
|
|
|
return cell
|
|
return cell
|
|
}
|
|
}
|
|
@@ -193,6 +223,32 @@ extension MVHomeController: MVBannerDataSource, MVBannerDelegate {
|
|
|
|
|
|
func banner(_: MVBanner, didSelectItemAt indexPath: IndexPath) {
|
|
func banner(_: MVBanner, didSelectItemAt indexPath: IndexPath) {
|
|
NSLog("didSelectItemAt %d", indexPath.row)
|
|
NSLog("didSelectItemAt %d", indexPath.row)
|
|
|
|
+
|
|
|
|
+ let cell: MVBannerCell? = banner.collectionView.cellForItem(at: indexPath) as? MVBannerCell
|
|
|
|
+
|
|
|
|
+ if(PQSingletoVideoPlayer.shared.player.isPlaying()){
|
|
|
|
+ cell?.pauseView.isHidden = false
|
|
|
|
+ PQSingletoVideoPlayer.shared.stopPlayer(isRemove: false)
|
|
|
|
+
|
|
|
|
+ }else{
|
|
|
|
+ PQSingletoVideoPlayer.shared.resetPlayer()
|
|
|
|
+ cell?.pauseView.isHidden = true
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ func pageControl(currentPage page: Int) {
|
|
|
|
+ BFLog(message: "page is \(page)")
|
|
|
|
+
|
|
|
|
+ let cell: MVBannerCell? = banner.collectionView.cellForItem(at: IndexPath.init(row: page, section: 0)) as? MVBannerCell
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if (mVideos.count > 0 && cell != nil) {
|
|
|
|
+ cell?.pauseView.isHidden = true
|
|
|
|
+ PQSingletoVideoPlayer.shared.configPlyer(videoData: mAllVideos[page], controllerView: cell!.iconIView)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -201,40 +257,36 @@ extension MVHomeController: MVBannerDataSource, MVBannerDelegate {
|
|
/// 卡点音乐相关代理
|
|
/// 卡点音乐相关代理
|
|
extension MVHomeController: UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout, UIScrollViewDelegate {
|
|
extension MVHomeController: UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout, UIScrollViewDelegate {
|
|
func collectionView(_: UICollectionView, numberOfItemsInSection _: Int) -> Int {
|
|
func collectionView(_: UICollectionView, numberOfItemsInSection _: Int) -> Int {
|
|
- return itemList.count
|
|
|
|
|
|
+ return mVideos.count
|
|
}
|
|
}
|
|
|
|
|
|
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
|
|
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
|
|
- let itemData: MVTagsModel = itemList[indexPath.item]
|
|
|
|
|
|
+ let itemData: MVHotVideoModel = mVideos[indexPath.item]
|
|
let cell = MVTagsCell.tagsCell(collectionView: collectionView, indexPath: indexPath)
|
|
let cell = MVTagsCell.tagsCell(collectionView: collectionView, indexPath: indexPath)
|
|
cell.bgmData = itemData
|
|
cell.bgmData = itemData
|
|
return cell
|
|
return cell
|
|
}
|
|
}
|
|
|
|
|
|
func collectionView(_ collectionView: UICollectionView, layout _: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
|
|
func collectionView(_ collectionView: UICollectionView, layout _: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
|
|
- let itemData: MVTagsModel = itemList[indexPath.item]
|
|
|
|
- let width:CGFloat = CGFloat(CGFloat((itemData.tagName ?? "" as String).ga_widthForComment(font:UIFont.boldSystemFont(ofSize: 17),height:17.0)) + 36.0 + 20.0)
|
|
|
|
|
|
+ let itemData: MVHotVideoModel = mVideos[indexPath.item]
|
|
|
|
+ let width:CGFloat = CGFloat(CGFloat((itemData.categoryName ).ga_widthForComment(font:UIFont.boldSystemFont(ofSize: 17),height:17.0)) + 36.0 + 20.0)
|
|
|
|
|
|
return CGSize(width: width, height: collectionView.frame.height)
|
|
return CGSize(width: width, height: collectionView.frame.height)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
func collectionView(_: UICollectionView, didSelectItemAt indexPath: IndexPath) {
|
|
func collectionView(_: UICollectionView, didSelectItemAt indexPath: IndexPath) {
|
|
- let itemData: MVTagsModel = itemList[lastIndexPath.item]
|
|
|
|
|
|
+ let itemData: MVHotVideoModel = mVideos[lastIndexPath.item]
|
|
itemData.isSelected = false
|
|
itemData.isSelected = false
|
|
lastIndexPath = indexPath
|
|
lastIndexPath = indexPath
|
|
- let itemDataNew: MVTagsModel = itemList[lastIndexPath.item]
|
|
|
|
|
|
+ let itemDataNew: MVHotVideoModel = mVideos[lastIndexPath.item]
|
|
itemDataNew.isSelected = true
|
|
itemDataNew.isSelected = true
|
|
collectionView.reloadData()
|
|
collectionView.reloadData()
|
|
}
|
|
}
|
|
|
|
|
|
- func scrollViewDidScroll(_: UIScrollView) {
|
|
|
|
-// if scroDidScroHandle != nil {
|
|
|
|
-// scroDidScroHandle!()
|
|
|
|
-// }
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
|
|
|
|
func collectionView(_: UICollectionView, willDisplay _: UICollectionViewCell, forItemAt indexPath: IndexPath) {
|
|
func collectionView(_: UICollectionView, willDisplay _: UICollectionViewCell, forItemAt indexPath: IndexPath) {
|
|
- let itemData: Any = itemList[indexPath.item]
|
|
|
|
|
|
+ let itemData: Any = mVideos[indexPath.item]
|
|
}
|
|
}
|
|
}
|
|
}
|