|
@@ -28,6 +28,9 @@ class PQSelecteMusicView: UIView {
|
|
|
var didSelectItemHandle:((_ isPlaying:Bool) -> Void)?
|
|
|
// 当前选择的分类
|
|
|
var currentSelectTag:PQStuckPointMusicTagsModel?
|
|
|
+
|
|
|
+ //搜索出来的歌曲要插入到热门的前面 有可能是多个
|
|
|
+ var searchMusiceDatas: [PQVoiceModel] = Array<PQVoiceModel>.init()
|
|
|
|
|
|
lazy var avPlayer: AVPlayer = {
|
|
|
let avPlayer = AVPlayer()
|
|
@@ -119,6 +122,18 @@ class PQSelecteMusicView: UIView {
|
|
|
fatalError("init(coder:) has not been implemented")
|
|
|
}
|
|
|
|
|
|
+ //插入数据
|
|
|
+ func insertSearchMusic(model:PQVoiceModel) {
|
|
|
+ model.isSelected = true
|
|
|
+ searchMusiceDatas.insert(model, at: 0)
|
|
|
+
|
|
|
+ //有搜索的数据
|
|
|
+// if(musicDatas.first?.name == "热门"){
|
|
|
+ musicDatas.insert(contentsOf: searchMusiceDatas, at: 0)
|
|
|
+// }
|
|
|
+
|
|
|
+ selectMusicCollection.reloadData()
|
|
|
+ }
|
|
|
func autolayout() {
|
|
|
categoryCollection.snp.makeConstraints { make in
|
|
|
make.height.equalTo(20)
|
|
@@ -171,6 +186,13 @@ class PQSelecteMusicView: UIView {
|
|
|
self?.pageNum = (self?.pageNum ?? 0) + 1
|
|
|
|
|
|
self?.musicDatas = self!.musicDatas + musicInfo
|
|
|
+
|
|
|
+ //有搜索的数据
|
|
|
+// if((self?.searchMusiceDatas.count ?? 0) > 0 && self!.musicDatas.first?.name == "热门"){
|
|
|
+ self?.musicDatas.insert(contentsOf: self?.searchMusiceDatas ?? Array.init(), at: 0)
|
|
|
+
|
|
|
+// }
|
|
|
+
|
|
|
self?.selectMusicCollection.reloadData()
|
|
|
}
|
|
|
|
|
@@ -262,6 +284,8 @@ extension PQSelecteMusicView: UICollectionViewDelegate, UICollectionViewDataSour
|
|
|
//暂停播放音乐
|
|
|
self?.pausePlayer()
|
|
|
|
|
|
+ PQEventTrackViewModel.baseReportUpload(businessType: .bt_buttonClick, objectType: .ot_shanyinApp_musicVideoPreview_musicSelect, pageSource: .sp_shanyinApp_main, extParams: ["musicName":(bgmData as? PQVoiceModel)?.musicName ?? "" ,"musicId":(bgmData as? PQVoiceModel)?.musicId ?? ""], remindmsg: "")
|
|
|
+
|
|
|
if self?.btnClickHandle != nil {
|
|
|
self?.btnClickHandle!(sender, bgmData)
|
|
|
|
|
@@ -299,12 +323,15 @@ extension PQSelecteMusicView: UICollectionViewDelegate, UICollectionViewDataSour
|
|
|
musicDatas.forEach { item in
|
|
|
item.isSelected = false
|
|
|
}
|
|
|
- musicDatas[indexPath.item].isSelected = true
|
|
|
- playStuckPointMusic(itemData: musicDatas[indexPath.item])
|
|
|
+ let music = musicDatas[indexPath.item]
|
|
|
+ music.isSelected = true
|
|
|
+ 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!(musicDatas[indexPath.item].isPlaying)
|
|
|
+ didSelectItemHandle!(music.isPlaying)
|
|
|
}
|
|
|
|
|
|
}else{
|
|
@@ -326,9 +353,13 @@ extension PQSelecteMusicView: UICollectionViewDelegate, UICollectionViewDataSour
|
|
|
|
|
|
}
|
|
|
|
|
|
- func collectionView(_: UICollectionView, willDisplay _: UICollectionViewCell, forItemAt indexPath: IndexPath) {
|
|
|
-
|
|
|
+ func collectionView(_ collectionView: UICollectionView, willDisplay _: UICollectionViewCell, forItemAt indexPath: IndexPath) {
|
|
|
|
|
|
+ if (collectionView == selectMusicCollection ){
|
|
|
+ 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: "")
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|