|
@@ -38,8 +38,8 @@ class PQSelecteMusicView: UIView {
|
|
|
BFLog(message: "AVPlayerItemDidPlayToEndTime = \(notify)")
|
|
|
avPlayer.seek(to: CMTime(value: CMTimeValue((self?.currentPlayData?.startTime ?? 0) * 1000), timescale: CMTimeScale(playerTimescale)))
|
|
|
|
|
|
+ self?.currentPlayData?.voiceStatue = .isPause
|
|
|
|
|
|
- self?.currentPlayData?.isPlaying = false
|
|
|
self?.selectMusicCollection.reloadData()
|
|
|
}
|
|
|
PQNotification.addObserver(forName: .AVPlayerItemNewErrorLogEntry, object: avPlayer.currentItem, queue: .main) { notify in
|
|
@@ -124,13 +124,14 @@ class PQSelecteMusicView: UIView {
|
|
|
|
|
|
//插入数据
|
|
|
func insertSearchMusic(model:PQVoiceModel) {
|
|
|
- model.isSelected = true
|
|
|
+
|
|
|
+ model.voiceStatue = .isSelected
|
|
|
searchMusiceDatas.insert(model, at: 0)
|
|
|
|
|
|
//有搜索的数据
|
|
|
-// if(musicDatas.first?.name == "热门"){
|
|
|
+ if(musicDatas.first?.cacheTagID == 425){
|
|
|
musicDatas.insert(contentsOf: searchMusiceDatas, at: 0)
|
|
|
-// }
|
|
|
+ }
|
|
|
|
|
|
selectMusicCollection.reloadData()
|
|
|
}
|
|
@@ -188,10 +189,10 @@ class PQSelecteMusicView: UIView {
|
|
|
self?.musicDatas = self!.musicDatas + musicInfo
|
|
|
|
|
|
//有搜索的数据
|
|
|
-// if((self?.searchMusiceDatas.count ?? 0) > 0 && self!.musicDatas.first?.name == "热门"){
|
|
|
+ if((self?.searchMusiceDatas.count ?? 0) > 0 && self!.musicDatas.first?.cacheTagID == 425){
|
|
|
self?.musicDatas.insert(contentsOf: self?.searchMusiceDatas ?? Array.init(), at: 0)
|
|
|
|
|
|
-// }
|
|
|
+ }
|
|
|
|
|
|
self?.selectMusicCollection.reloadData()
|
|
|
}
|
|
@@ -219,15 +220,16 @@ class PQSelecteMusicView: UIView {
|
|
|
playerItem?.addObserver(self, forKeyPath: "error", options: .new, context: nil)
|
|
|
avPlayer.seek(to: CMTime(value: CMTimeValue((itemData?.startTime ?? 0) * playerTimescale), timescale: CMTimeScale(playerTimescale)))
|
|
|
avPlayer.play()
|
|
|
- itemData?.isPlaying = true
|
|
|
+ itemData?.voiceStatue = .isPlaying
|
|
|
|
|
|
currentPlayData = itemData
|
|
|
} else if itemData != nil, avPlayer.rate == 0.0 {
|
|
|
avPlayer.play()
|
|
|
- itemData?.isPlaying = true
|
|
|
+ itemData?.voiceStatue = .isPlaying
|
|
|
} else {
|
|
|
avPlayer.pause()
|
|
|
- itemData?.isPlaying = false
|
|
|
+
|
|
|
+ itemData?.voiceStatue = .isPause
|
|
|
|
|
|
}
|
|
|
if isClearCurrentMusic {
|
|
@@ -239,7 +241,7 @@ class PQSelecteMusicView: UIView {
|
|
|
//暂停播放音乐 并刷新 UI
|
|
|
func pausePlayer() {
|
|
|
avPlayer.pause()
|
|
|
- currentPlayData?.isPlaying = false
|
|
|
+ currentPlayData?.voiceStatue = .isPause
|
|
|
selectMusicCollection.reloadData()
|
|
|
}
|
|
|
|
|
@@ -290,6 +292,14 @@ extension PQSelecteMusicView: UICollectionViewDelegate, UICollectionViewDataSour
|
|
|
self?.btnClickHandle!(sender, bgmData)
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+ let musicIndex = self?.musicDatas.firstIndex(where: { (music) -> Bool in
|
|
|
+ (music.musicId == (bgmData as? PQVoiceModel)?.musicId)
|
|
|
+ })
|
|
|
+
|
|
|
+ self?.musicDatas[musicIndex ?? 0].voiceStatue = .isSelected
|
|
|
+
|
|
|
+ self?.selectMusicCollection.reloadData()
|
|
|
}
|
|
|
|
|
|
//自动请求下一页数据
|
|
@@ -321,17 +331,18 @@ extension PQSelecteMusicView: UICollectionViewDelegate, UICollectionViewDataSour
|
|
|
//歌曲列表
|
|
|
if (collectionView == selectMusicCollection ){
|
|
|
musicDatas.forEach { item in
|
|
|
- item.isSelected = false
|
|
|
+
|
|
|
+ item.voiceStatue = .isNormal
|
|
|
}
|
|
|
let music = musicDatas[indexPath.item]
|
|
|
- music.isSelected = true
|
|
|
+ music.voiceStatue = .isSelected
|
|
|
playStuckPointMusic(itemData:music)
|
|
|
selectMusicCollection.reloadData()
|
|
|
|
|
|
PQEventTrackViewModel.baseReportUpload(businessType: .bt_buttonClick, objectType: .ot_shanyinApp_musicVideoPreview_musicCategorySelect, pageSource: .sp_shanyinApp_main, extParams: ["categoryName":music.tagsInfo?.tagName,"categoryId":music.tagsInfo?.tagId], remindmsg: "")
|
|
|
|
|
|
if didSelectItemHandle != nil {
|
|
|
- didSelectItemHandle!(music.isPlaying)
|
|
|
+ didSelectItemHandle!(music.voiceStatue == .isPlaying)
|
|
|
}
|
|
|
|
|
|
}else{
|
|
@@ -359,7 +370,7 @@ extension PQSelecteMusicView: UICollectionViewDelegate, UICollectionViewDataSour
|
|
|
let music = musicDatas[indexPath.item]
|
|
|
|
|
|
PQEventTrackViewModel.baseReportUpload(businessType: .bt_buttonClick, objectType: .ot_shanyinApp_musicVideoPreview_musicView, pageSource: .sp_shanyinApp_main, extParams: ["musicName":music.musicName ?? "" ,"musicId":music.musicId ?? ""], remindmsg: "")
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -504,26 +515,50 @@ class PQSelectMusicCell: UICollectionViewCell {
|
|
|
|
|
|
musicNameLab.text = bgmData?.musicName ?? ""
|
|
|
|
|
|
- if bgmData?.isSelected ?? false {
|
|
|
+ if bgmData?.voiceStatue == .isSelected{
|
|
|
playImageView.isHidden = false
|
|
|
- if bgmData?.isPlaying ?? false {
|
|
|
- playImageView.image = nil
|
|
|
- playImageView.kf.setImage(with: URL(fileURLWithPath: Bundle().BF_mainbundle().path(forResource: "stuckPoint_music_playing", ofType: ".gif")!))
|
|
|
-
|
|
|
- } else {
|
|
|
- playImageView.image = UIImage().BF_Image(named: "stuckPoint_music_pause")
|
|
|
- }
|
|
|
imageMaskView.isHidden = false
|
|
|
- } else {
|
|
|
+ playImageView.image = UIImage().BF_Image(named: "stuckPoint_music_selected")
|
|
|
+
|
|
|
+ } else if bgmData?.voiceStatue == .isPlaying{
|
|
|
+ playImageView.isHidden = false
|
|
|
+ imageMaskView.isHidden = false
|
|
|
+ playImageView.image = nil
|
|
|
+ playImageView.kf.setImage(with: URL(fileURLWithPath: Bundle().BF_mainbundle().path(forResource: "stuckPoint_music_playing", ofType: ".gif")!))
|
|
|
+
|
|
|
+ } else if bgmData?.voiceStatue == .isPause{
|
|
|
+ playImageView.isHidden = false
|
|
|
+ imageMaskView.isHidden = false
|
|
|
+ playImageView.image = UIImage().BF_Image(named: "stuckPoint_music_pause")
|
|
|
+
|
|
|
+ }else {
|
|
|
playImageView.isHidden = true
|
|
|
playImageView.image = nil
|
|
|
|
|
|
imageMaskView.isHidden = true
|
|
|
}
|
|
|
|
|
|
- confirmBtn.isHidden = !(bgmData?.isSelected ?? false)
|
|
|
+// if bgmData?.voiceStatue == .isSelected{
|
|
|
+// playImageView.isHidden = false
|
|
|
+// imageMaskView.isHidden = false
|
|
|
+// if bgmData?.voiceStatue == .isPlaying {
|
|
|
+// playImageView.image = nil
|
|
|
+// playImageView.kf.setImage(with: URL(fileURLWithPath: Bundle().BF_mainbundle().path(forResource: "stuckPoint_music_playing", ofType: ".gif")!))
|
|
|
+//
|
|
|
+// } else {
|
|
|
+// playImageView.image = UIImage().BF_Image(named: "stuckPoint_music_pause")
|
|
|
+// }
|
|
|
+//
|
|
|
+// } else {
|
|
|
+// playImageView.isHidden = true
|
|
|
+// playImageView.image = nil
|
|
|
+//
|
|
|
+// imageMaskView.isHidden = true
|
|
|
+// }
|
|
|
+
|
|
|
+ confirmBtn.isHidden = !(bgmData?.voiceStatue == .isPause || bgmData?.voiceStatue == .isPlaying)
|
|
|
|
|
|
- musicNameLab.textColor = (bgmData?.isSelected ?? false) ? UIColor.hexColor(hexadecimal: PQBFConfig.shared.styleColor.rawValue): UIColor.hexColor(hexadecimal: "#959595")
|
|
|
+ musicNameLab.textColor = (bgmData?.voiceStatue == .isSelected) ? UIColor.hexColor(hexadecimal: PQBFConfig.shared.styleColor.rawValue): UIColor.hexColor(hexadecimal: "#959595")
|
|
|
|
|
|
}
|
|
|
|