|
@@ -9,7 +9,7 @@ import BFFramework
|
|
class MVHomeController: MVBaseController {
|
|
class MVHomeController: MVBaseController {
|
|
// 视频播放列表
|
|
// 视频播放列表
|
|
private var viewListView: MVBanner = {
|
|
private var viewListView: MVBanner = {
|
|
- let videoListView = MVBanner(frame: .zero, margin: 30, lineSpacing: 12, minScale: MVBanner.Scale(scale: 1))
|
|
|
|
|
|
+ let videoListView = MVBanner(frame: .zero, margin: 30, lineSpacing: 0, minScale: MVBanner.Scale(scale: 1))
|
|
videoListView.backgroundColor = UIColor.white
|
|
videoListView.backgroundColor = UIColor.white
|
|
|
|
|
|
videoListView.register(classCellType: MVBannerCell.self)
|
|
videoListView.register(classCellType: MVBannerCell.self)
|
|
@@ -77,12 +77,9 @@ 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()
|
|
|
|
-
|
|
|
|
- // 是否点击的再创作
|
|
|
|
- var isCreateVideo: Bool = false
|
|
|
|
-
|
|
|
|
|
|
+ var lastBnnerSelectIndex: IndexPath = IndexPath.init(row: 0, section: 0)
|
|
|
|
+ //是否点击的再创作
|
|
|
|
+ var isCreateVideo:Bool = false
|
|
deinit {
|
|
deinit {
|
|
PQNotification.removeObserver(self)
|
|
PQNotification.removeObserver(self)
|
|
}
|
|
}
|
|
@@ -126,11 +123,8 @@ 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?.viewListView.reloadData()
|
|
self?.viewListView.reloadData()
|
|
-
|
|
|
|
- // 自动播放第一个视频 确保 reloaddata 完成
|
|
|
|
-
|
|
|
|
|
|
+ //自动播放第一个视频 确保 reloaddata 完成
|
|
self?.playVideo(page: 0)
|
|
self?.playVideo(page: 0)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -183,7 +177,6 @@ class MVHomeController: MVBaseController {
|
|
protocalView.remindBlock = { [weak self] sender, webUrl in
|
|
protocalView.remindBlock = { [weak self] sender, webUrl in
|
|
if sender == nil, webUrl != nil {
|
|
if sender == nil, webUrl != nil {
|
|
let detail = PQBaseWebViewController()
|
|
let detail = PQBaseWebViewController()
|
|
- detail.evaluateJavaScript = "document.getElementsByTagName('body')[0].style.webkitTextSizeAdjust='210%'"
|
|
|
|
detail.baseUrl = webUrl
|
|
detail.baseUrl = webUrl
|
|
self?.navigationController?.pushViewController(detail, animated: true)
|
|
self?.navigationController?.pushViewController(detail, animated: true)
|
|
}
|
|
}
|
|
@@ -310,7 +303,7 @@ class MVHomeController: MVBaseController {
|
|
|
|
|
|
// 再创作视频
|
|
// 再创作视频
|
|
func createVideo(indexPath: IndexPath) {
|
|
func createVideo(indexPath: IndexPath) {
|
|
- if enableLogin() {
|
|
|
|
|
|
+ if(enableLogin() && mAllVideos.count > indexPath.row){
|
|
PQStuckPointViewModel.stuckPointProjectMusicInfo(projectId: mAllVideos[indexPath.row].reCreateVideoData?.projectId ?? "") { musicData, _ in
|
|
PQStuckPointViewModel.stuckPointProjectMusicInfo(projectId: mAllVideos[indexPath.row].reCreateVideoData?.projectId ?? "") { musicData, _ in
|
|
if musicData != nil {
|
|
if musicData != nil {
|
|
let vc = PQStuckPointMaterialController()
|
|
let vc = PQStuckPointMaterialController()
|
|
@@ -331,10 +324,7 @@ extension MVHomeController: MVBannerDataSource, MVBannerDelegate {
|
|
|
|
|
|
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.cornerRadius = 10
|
|
|
|
- cell.contentView.backgroundColor = UIColor.white
|
|
|
|
-
|
|
|
|
|
|
+
|
|
cell.videoData = mAllVideos[indexPath.row]
|
|
cell.videoData = mAllVideos[indexPath.row]
|
|
cell.reCreateBtnClicHandle = { [weak self] _, _ in
|
|
cell.reCreateBtnClicHandle = { [weak self] _, _ in
|
|
BFLog(message: "点击了创同款")
|
|
BFLog(message: "点击了创同款")
|
|
@@ -367,16 +357,18 @@ extension MVHomeController: MVBannerDataSource, MVBannerDelegate {
|
|
changePlayerStatus(indexPath: indexPath)
|
|
changePlayerStatus(indexPath: indexPath)
|
|
}
|
|
}
|
|
|
|
|
|
- func playVideo(page: Int) {
|
|
|
|
|
|
+ func playVideo(page: Int){
|
|
DispatchQueue.main.async {
|
|
DispatchQueue.main.async {
|
|
let cell: MVBannerCell? = self.viewListView.collectionView.cellForItem(at: IndexPath(row: page, section: 0)) as? MVBannerCell
|
|
let cell: MVBannerCell? = self.viewListView.collectionView.cellForItem(at: IndexPath(row: page, section: 0)) as? MVBannerCell
|
|
let showProtocal: String? = getUserDefaults(key: cShowProtocal) as? String
|
|
let showProtocal: String? = getUserDefaults(key: cShowProtocal) as? String
|
|
if self.mVideos.count > 0, cell != nil, showProtocal != nil, showProtocal == "1" {
|
|
if self.mVideos.count > 0, cell != nil, showProtocal != nil, showProtocal == "1" {
|
|
cell?.pauseView.isHidden = true
|
|
cell?.pauseView.isHidden = true
|
|
- PQSingletoVideoPlayer.shared.configPlyer(videoData: self.mAllVideos[page], controllerView: cell!.converView)
|
|
|
|
|
|
+ let videoInfo = self.mAllVideos[page]
|
|
|
|
+ videoInfo.playProgress = 0
|
|
|
|
+ PQSingletoVideoPlayer.shared.configPlyer(videoData:videoInfo, controllerView: cell!.converView)
|
|
|
|
|
|
let hotVideoIndex = self.mVideos.firstIndex(where: { (items) -> Bool in
|
|
let hotVideoIndex = self.mVideos.firstIndex(where: { (items) -> Bool in
|
|
- items.categoryName == self.mAllVideos[page].categoryName
|
|
|
|
|
|
+ items.categoryName == videoInfo.categoryName
|
|
})
|
|
})
|
|
|
|
|
|
BFLog(message: "播放的视频分类为:\(String(describing: self.mVideos[hotVideoIndex ?? 0].categoryName)) page is :\(page)")
|
|
BFLog(message: "播放的视频分类为:\(String(describing: self.mVideos[hotVideoIndex ?? 0].categoryName)) page is :\(page)")
|
|
@@ -395,6 +387,7 @@ extension MVHomeController: MVBannerDataSource, MVBannerDelegate {
|
|
BFLog(message: "播放不成功: cell:\(String(describing: cell)) mVideos:\(self.mVideos.count) showProtocal: is \(String(describing: showProtocal))")
|
|
BFLog(message: "播放不成功: cell:\(String(describing: cell)) mVideos:\(self.mVideos.count) showProtocal: is \(String(describing: showProtocal))")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
func pageControl(currentPage page: Int) {
|
|
func pageControl(currentPage page: Int) {
|
|
@@ -444,6 +437,9 @@ extension MVHomeController: UICollectionViewDelegate, UICollectionViewDataSource
|
|
}
|
|
}
|
|
viewListView.scrollToItem(at: videosCount, animated: false)
|
|
viewListView.scrollToItem(at: videosCount, animated: false)
|
|
|
|
|
|
- playVideo(page: videosCount)
|
|
|
|
|
|
+ DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.1) {
|
|
|
|
+ self.playVideo(page: videosCount)
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
}
|
|
}
|