|
@@ -7,8 +7,8 @@
|
|
|
|
|
|
import BFFramework
|
|
import BFFramework
|
|
class MVHomeController: MVBaseController {
|
|
class MVHomeController: MVBaseController {
|
|
- // 当前选择的位置
|
|
|
|
- var lastIndexPath: IndexPath = IndexPath(row: 0, section: 0)
|
|
|
|
|
|
+
|
|
|
|
+
|
|
private var banner: MVBanner = {
|
|
private var banner: MVBanner = {
|
|
let banner = MVBanner(frame: .zero, margin: 30, lineSpacing: 12, minScale: MVBanner.Scale(scale: 1))
|
|
let banner = MVBanner(frame: .zero, margin: 30, lineSpacing: 12, minScale: MVBanner.Scale(scale: 1))
|
|
banner.backgroundColor = UIColor.white
|
|
banner.backgroundColor = UIColor.white
|
|
@@ -78,6 +78,18 @@ class MVHomeController: MVBaseController {
|
|
var mVideos:Array = Array<MVHotVideoModel>.init()
|
|
var mVideos:Array = Array<MVHotVideoModel>.init()
|
|
|
|
|
|
var mAllVideos:Array = Array<PQVideoListModel>.init()
|
|
var mAllVideos:Array = Array<PQVideoListModel>.init()
|
|
|
|
+
|
|
|
|
+ var lastBnnerSelectIndex:IndexPath = IndexPath.init()
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ override func viewWillDisappear(_ animated: Bool) {
|
|
|
|
+ super.viewWillDisappear(animated)
|
|
|
|
+
|
|
|
|
+ //停止播放
|
|
|
|
+ let cell: MVBannerCell? = banner.collectionView.cellForItem(at: lastBnnerSelectIndex) as? MVBannerCell
|
|
|
|
+ cell?.pauseView.isHidden = false
|
|
|
|
+ PQSingletoVideoPlayer.shared.stopPlayer(isRemove: false)
|
|
|
|
+ }
|
|
|
|
|
|
override func viewDidLoad() {
|
|
override func viewDidLoad() {
|
|
super.viewDidLoad()
|
|
super.viewDidLoad()
|
|
@@ -111,17 +123,17 @@ class MVHomeController: MVBaseController {
|
|
}
|
|
}
|
|
|
|
|
|
self?.banner.reloadData()
|
|
self?.banner.reloadData()
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+
|
|
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.init()) as? MVBannerCell
|
|
|
|
+
|
|
|
|
+ cell?.progressView.progress = playProgress / loadProgress
|
|
|
|
+// cell?.progressView.progress = 0.5
|
|
|
|
+
|
|
|
|
|
|
}
|
|
}
|
|
PQSingletoVideoPlayer.shared.playStatusBloc = { [weak self] status in
|
|
PQSingletoVideoPlayer.shared.playStatusBloc = { [weak self] status in
|
|
@@ -194,6 +206,45 @@ class MVHomeController: MVBaseController {
|
|
break
|
|
break
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ //再创作视频
|
|
|
|
+ func createVideo(indexPath: IndexPath) {
|
|
|
|
+ // 无网
|
|
|
|
+ if !isNetConnected() {
|
|
|
|
+
|
|
|
|
+ let remindData:PQBaseModel = PQBaseModel()
|
|
|
|
+ remindData.title = "似乎已断开与互联网的连接"
|
|
|
|
+
|
|
|
|
+ let remindView = PQRemindView(frame: CGRect(x: 0, y: 0, width: cScreenWidth, height: cScreenHeigth))
|
|
|
|
+ UIApplication.shared.keyWindow?.addSubview(remindView)
|
|
|
|
+ remindView.remindData = remindData
|
|
|
|
+ remindView.remindBlock = { [weak self] sender, _ in
|
|
|
|
+ if sender.tag == 2 {
|
|
|
|
+ openAppSetting()
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if !BFLoginUserInfo.shared.isLogin() {
|
|
|
|
+ let vc = MVLoginController()
|
|
|
|
+ vc.modalPresentationStyle = .fullScreen
|
|
|
|
+ present(vc, animated: true, completion: nil)
|
|
|
|
+
|
|
|
|
+ }else{
|
|
|
|
+ PQStuckPointViewModel.stuckPointProjectMusicInfo(projectId: mAllVideos[indexPath.row].reCreateVideoData?.projectId ?? "") { musicData, _ in
|
|
|
|
+ if musicData != nil{
|
|
|
|
+ let vc = PQStuckPointMaterialController.init()
|
|
|
|
+ vc.reCreateMusicData = musicData
|
|
|
|
+ self.navigationController?.pushViewController(vc, animated: true)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
// MARK: - MVBannerDataSource
|
|
// MARK: - MVBannerDataSource
|
|
@@ -212,17 +263,16 @@ extension MVHomeController: MVBannerDataSource, MVBannerDelegate {
|
|
cell.videoData = mAllVideos[indexPath.row]
|
|
cell.videoData = mAllVideos[indexPath.row]
|
|
cell.reCreateBtnClicHandle = { [weak self] _, _ in
|
|
cell.reCreateBtnClicHandle = { [weak self] _, _ in
|
|
BFLog(message: "点击了创同款")
|
|
BFLog(message: "点击了创同款")
|
|
- PQSingletoVideoPlayer.shared.stopPlayer(isRemove: false)
|
|
|
|
|
|
+ self?.createVideo(indexPath: indexPath)
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
return cell
|
|
return cell
|
|
}
|
|
}
|
|
-
|
|
|
|
- // MARK: - GXBannerDelegate
|
|
|
|
-
|
|
|
|
- func banner(_: MVBanner, didSelectItemAt indexPath: IndexPath) {
|
|
|
|
- NSLog("didSelectItemAt %d", indexPath.row)
|
|
|
|
|
|
+
|
|
|
|
+ func changePlayerStatus(indexPath: IndexPath){
|
|
|
|
+
|
|
|
|
|
|
let cell: MVBannerCell? = banner.collectionView.cellForItem(at: indexPath) as? MVBannerCell
|
|
let cell: MVBannerCell? = banner.collectionView.cellForItem(at: indexPath) as? MVBannerCell
|
|
|
|
|
|
@@ -234,6 +284,16 @@ extension MVHomeController: MVBannerDataSource, MVBannerDelegate {
|
|
PQSingletoVideoPlayer.shared.resetPlayer()
|
|
PQSingletoVideoPlayer.shared.resetPlayer()
|
|
cell?.pauseView.isHidden = true
|
|
cell?.pauseView.isHidden = true
|
|
}
|
|
}
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // MARK: - GXBannerDelegate
|
|
|
|
+
|
|
|
|
+ func banner(_: MVBanner, didSelectItemAt indexPath: IndexPath) {
|
|
|
|
+ NSLog("didSelectItemAt %d", indexPath.row)
|
|
|
|
+ lastBnnerSelectIndex = indexPath
|
|
|
|
+
|
|
|
|
+ changePlayerStatus(indexPath: indexPath)
|
|
|
|
+
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -245,16 +305,27 @@ extension MVHomeController: MVBannerDataSource, MVBannerDelegate {
|
|
|
|
|
|
if (mVideos.count > 0 && cell != nil) {
|
|
if (mVideos.count > 0 && cell != nil) {
|
|
cell?.pauseView.isHidden = true
|
|
cell?.pauseView.isHidden = true
|
|
- PQSingletoVideoPlayer.shared.configPlyer(videoData: mAllVideos[page], controllerView: cell!.iconIView)
|
|
|
|
|
|
+ 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
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ mVideos[(hotVides?.categoryId ?? 0) - 1].isSelected = true
|
|
|
|
+ collectionView.reloadData()
|
|
|
|
+
|
|
|
|
+ lastBnnerSelectIndex = IndexPath.init(row: page, section: 0)
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-// MARK: - 卡点音乐相关代理
|
|
|
|
|
|
+// MARK: - 划动分类相关代理
|
|
|
|
|
|
-/// 卡点音乐相关代理
|
|
|
|
|
|
+///
|
|
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 mVideos.count
|
|
return mVideos.count
|
|
@@ -276,17 +347,29 @@ extension MVHomeController: UICollectionViewDelegate, UICollectionViewDataSource
|
|
|
|
|
|
|
|
|
|
func collectionView(_: UICollectionView, didSelectItemAt indexPath: IndexPath) {
|
|
func collectionView(_: UICollectionView, didSelectItemAt indexPath: IndexPath) {
|
|
- let itemData: MVHotVideoModel = mVideos[lastIndexPath.item]
|
|
|
|
- itemData.isSelected = false
|
|
|
|
- lastIndexPath = indexPath
|
|
|
|
- let itemDataNew: MVHotVideoModel = mVideos[lastIndexPath.item]
|
|
|
|
|
|
+
|
|
|
|
+ for hot in mVideos {
|
|
|
|
+ hot.isSelected = false
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ let itemDataNew: MVHotVideoModel = mVideos[indexPath.item]
|
|
itemDataNew.isSelected = true
|
|
itemDataNew.isSelected = true
|
|
collectionView.reloadData()
|
|
collectionView.reloadData()
|
|
|
|
+
|
|
|
|
+ //找出当前选择分类之前的视频数量和
|
|
|
|
+ var videosCount:Int = 0
|
|
|
|
+ if(indexPath.row != 0){
|
|
|
|
+
|
|
|
|
+ for i in 0...indexPath.row - 1 {
|
|
|
|
+ videosCount = videosCount + mVideos[i].videos.count
|
|
|
|
+ }
|
|
|
|
+ BFLog(message: "indexPath 选择\(indexPath.item) 之前的视频合\(videosCount)")
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ banner.scrollToItem(at: videosCount, animated: true)
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
|
|
-
|
|
|
|
- func collectionView(_: UICollectionView, willDisplay _: UICollectionViewCell, forItemAt indexPath: IndexPath) {
|
|
|
|
- let itemData: Any = mVideos[indexPath.item]
|
|
|
|
- }
|
|
|
|
}
|
|
}
|