|
@@ -16,16 +16,22 @@ class PQSelecteMusicView: UIView {
|
|
// 当前页码
|
|
// 当前页码
|
|
var pageNum: Int = 0
|
|
var pageNum: Int = 0
|
|
|
|
|
|
- // 当前播放的音乐
|
|
|
|
|
|
+ // 当前视频使用的音乐数据
|
|
|
|
+ var currentPlayingInVideoData : PQVoiceModel?{
|
|
|
|
+ willSet{
|
|
|
|
+ BFLog(1, message: "name:\(currentPlayingInVideoData?.musicName)")
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // 当前试听播放的音乐数据
|
|
var currentPlayData: PQVoiceModel?
|
|
var currentPlayData: PQVoiceModel?
|
|
- // 当前播放的视频
|
|
|
|
|
|
+ // 当前播放的音频
|
|
var playerItem: AVPlayerItem?
|
|
var playerItem: AVPlayerItem?
|
|
|
|
|
|
// 按钮点击的回调
|
|
// 按钮点击的回调
|
|
var btnClickHandle: ((_ sender: UIButton, _ bgmData: Any?) -> Void)?
|
|
var btnClickHandle: ((_ sender: UIButton, _ bgmData: Any?) -> Void)?
|
|
|
|
|
|
// 点击播放一个歌,回调
|
|
// 点击播放一个歌,回调
|
|
- var didSelectItemHandle:((_ isPlaying:Bool) -> Void)?
|
|
|
|
|
|
+ var didSelectItemHandle:((_ statue:voiceStatue) -> Void)?
|
|
// 当前选择的分类
|
|
// 当前选择的分类
|
|
var currentSelectTag:PQStuckPointMusicTagsModel?
|
|
var currentSelectTag:PQStuckPointMusicTagsModel?
|
|
|
|
|
|
@@ -169,7 +175,7 @@ class PQSelecteMusicView: UIView {
|
|
musicDatas.remove(at: musicIndex!)
|
|
musicDatas.remove(at: musicIndex!)
|
|
musicDatas.insert(selectMusicData, at: 0)
|
|
musicDatas.insert(selectMusicData, at: 0)
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ self.currentPlayingInVideoData = model
|
|
selectMusicCollection.reloadData()
|
|
selectMusicCollection.reloadData()
|
|
|
|
|
|
//划动到选择的音乐位置
|
|
//划动到选择的音乐位置
|
|
@@ -246,6 +252,7 @@ class PQSelecteMusicView: UIView {
|
|
//第一次进入插入的歌曲,插入后置空 如果 不存在只插入一次 防止重
|
|
//第一次进入插入的歌曲,插入后置空 如果 不存在只插入一次 防止重
|
|
if(self?.firstInsertVoiceModel != nil){
|
|
if(self?.firstInsertVoiceModel != nil){
|
|
self?.insertSearchMusic(model: (self?.firstInsertVoiceModel)!)
|
|
self?.insertSearchMusic(model: (self?.firstInsertVoiceModel)!)
|
|
|
|
+ self?.currentPlayingInVideoData = self?.firstInsertVoiceModel
|
|
self?.firstInsertVoiceModel = nil
|
|
self?.firstInsertVoiceModel = nil
|
|
}
|
|
}
|
|
|
|
|
|
@@ -346,7 +353,7 @@ extension PQSelecteMusicView: UICollectionViewDelegate, UICollectionViewDataSour
|
|
|
|
|
|
//暂停播放音乐
|
|
//暂停播放音乐
|
|
self?.pausePlayer()
|
|
self?.pausePlayer()
|
|
-
|
|
|
|
|
|
+ self?.currentPlayingInVideoData = bgmData as? PQVoiceModel
|
|
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: "")
|
|
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 {
|
|
if self?.btnClickHandle != nil {
|
|
@@ -370,6 +377,8 @@ extension PQSelecteMusicView: UICollectionViewDelegate, UICollectionViewDataSour
|
|
}
|
|
}
|
|
return cell
|
|
return cell
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
let itemData: Any = catageryDatas[indexPath.item]
|
|
let itemData: Any = catageryDatas[indexPath.item]
|
|
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: String(describing: PQSelectMusicTagsCell.self), for: indexPath) as! PQSelectMusicTagsCell
|
|
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: String(describing: PQSelectMusicTagsCell.self), for: indexPath) as! PQSelectMusicTagsCell
|
|
cell.tagData = itemData as? PQStuckPointMusicTagsModel
|
|
cell.tagData = itemData as? PQStuckPointMusicTagsModel
|
|
@@ -392,19 +401,23 @@ extension PQSelecteMusicView: UICollectionViewDelegate, UICollectionViewDataSour
|
|
//歌曲列表
|
|
//歌曲列表
|
|
if (collectionView == selectMusicCollection ){
|
|
if (collectionView == selectMusicCollection ){
|
|
musicDatas.forEach { item in
|
|
musicDatas.forEach { item in
|
|
-
|
|
|
|
item.voiceStatue = .isNormal
|
|
item.voiceStatue = .isNormal
|
|
}
|
|
}
|
|
let music = musicDatas[indexPath.item]
|
|
let music = musicDatas[indexPath.item]
|
|
music.voiceStatue = .isSelected
|
|
music.voiceStatue = .isSelected
|
|
- playStuckPointMusic(itemData:music)
|
|
|
|
|
|
+ if music.musicId != currentPlayingInVideoData?.musicId{
|
|
|
|
+ playStuckPointMusic(itemData:music)
|
|
|
|
+ }
|
|
selectMusicCollection.reloadData()
|
|
selectMusicCollection.reloadData()
|
|
-
|
|
|
|
PQEventTrackViewModel.baseReportUpload(businessType: .bt_buttonClick, objectType: .ot_shanyinApp_musicVideoPreview_musicCategorySelect, pageSource: .sp_shanyinApp_main, extParams: ["categoryName":currentSelectTag?.tagName ?? "","categoryId":currentSelectTag?.tagId ?? ""], remindmsg: "")
|
|
PQEventTrackViewModel.baseReportUpload(businessType: .bt_buttonClick, objectType: .ot_shanyinApp_musicVideoPreview_musicCategorySelect, pageSource: .sp_shanyinApp_main, extParams: ["categoryName":currentSelectTag?.tagName ?? "","categoryId":currentSelectTag?.tagId ?? ""], remindmsg: "")
|
|
|
|
|
|
- if didSelectItemHandle != nil {
|
|
|
|
- didSelectItemHandle!(music.voiceStatue == .isPlaying)
|
|
|
|
|
|
+ if music.musicId != currentPlayingInVideoData?.musicId{
|
|
|
|
+// BFLog(1, message: "预览:\(music.musicName) 当前:\(currentPlayingInVideoData?.musicName)")
|
|
|
|
+ if didSelectItemHandle != nil {
|
|
|
|
+ didSelectItemHandle!(music.voiceStatue)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
|
|
}else{
|
|
}else{
|
|
|
|
|