|
@@ -277,6 +277,14 @@ class PQSelecteMusicView: UIView {
|
|
avPlayer.pause()
|
|
avPlayer.pause()
|
|
playerItem?.removeObserver(self, forKeyPath: "status")
|
|
playerItem?.removeObserver(self, forKeyPath: "status")
|
|
playerItem?.removeObserver(self, forKeyPath: "error")
|
|
playerItem?.removeObserver(self, forKeyPath: "error")
|
|
|
|
+
|
|
|
|
+ if itemData!.musicId == currentPlayingInVideoData?.musicId {
|
|
|
|
+ itemData?.voiceStatue = .isSelected
|
|
|
|
+ currentPlayData = itemData
|
|
|
|
+ playerItem = nil
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
playerItem = AVPlayerItem(url: URL(string: itemData?.musicPath ?? "")!)
|
|
playerItem = AVPlayerItem(url: URL(string: itemData?.musicPath ?? "")!)
|
|
if (itemData?.endTime ?? 0) > 0, (itemData?.endTime ?? 0) > (itemData?.startTime ?? 0) {
|
|
if (itemData?.endTime ?? 0) > 0, (itemData?.endTime ?? 0) > (itemData?.startTime ?? 0) {
|
|
playerItem?.forwardPlaybackEndTime = CMTime(value: CMTimeValue((itemData?.endTime ?? 0) * playerTimescale), timescale: CMTimeScale(playerTimescale))
|
|
playerItem?.forwardPlaybackEndTime = CMTime(value: CMTimeValue((itemData?.endTime ?? 0) * playerTimescale), timescale: CMTimeScale(playerTimescale))
|
|
@@ -290,11 +298,12 @@ class PQSelecteMusicView: UIView {
|
|
|
|
|
|
currentPlayData = itemData
|
|
currentPlayData = itemData
|
|
} else if itemData != nil, avPlayer.rate == 0.0 {
|
|
} else if itemData != nil, avPlayer.rate == 0.0 {
|
|
- avPlayer.play()
|
|
|
|
- itemData?.voiceStatue = .isPlaying
|
|
|
|
|
|
+ if itemData?.musicId != currentPlayingInVideoData?.musicId {
|
|
|
|
+ avPlayer.play()
|
|
|
|
+ itemData?.voiceStatue = .isPlaying
|
|
|
|
+ }
|
|
} else {
|
|
} else {
|
|
avPlayer.pause()
|
|
avPlayer.pause()
|
|
-
|
|
|
|
itemData?.voiceStatue = .isPause
|
|
itemData?.voiceStatue = .isPause
|
|
|
|
|
|
}
|
|
}
|
|
@@ -350,11 +359,15 @@ extension PQSelecteMusicView: UICollectionViewDelegate, UICollectionViewDataSour
|
|
|
|
|
|
let itemData: Any = musicDatas[indexPath.item]
|
|
let itemData: Any = musicDatas[indexPath.item]
|
|
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: String(describing: PQSelectMusicCell.self), for: indexPath) as! PQSelectMusicCell
|
|
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: String(describing: PQSelectMusicCell.self), for: indexPath) as! PQSelectMusicCell
|
|
|
|
+ if (currentPlayingInVideoData?.musicId != nil && currentPlayingInVideoData?.musicId == (itemData as? PQVoiceModel)?.musicId){
|
|
|
|
+ (itemData as? PQVoiceModel)?.voiceStatue = .isSelected
|
|
|
|
+ }
|
|
cell.bgmData = itemData as? PQVoiceModel
|
|
cell.bgmData = itemData as? PQVoiceModel
|
|
cell.btnClickHandle = { [weak self] sender, bgmData in
|
|
cell.btnClickHandle = { [weak self] sender, bgmData in
|
|
|
|
|
|
//暂停播放音乐
|
|
//暂停播放音乐
|
|
self?.pausePlayer()
|
|
self?.pausePlayer()
|
|
|
|
+ self?.currentPlayingInVideoData?.voiceStatue = .isNormal
|
|
self?.currentPlayingInVideoData = bgmData as? PQVoiceModel
|
|
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: "")
|
|
|
|
|
|
@@ -407,19 +420,21 @@ extension PQSelecteMusicView: UICollectionViewDelegate, UICollectionViewDataSour
|
|
}
|
|
}
|
|
let music = musicDatas[indexPath.item]
|
|
let music = musicDatas[indexPath.item]
|
|
music.voiceStatue = .isSelected
|
|
music.voiceStatue = .isSelected
|
|
- if music.musicId != currentPlayingInVideoData?.musicId{
|
|
|
|
- playStuckPointMusic(itemData:music)
|
|
|
|
- }
|
|
|
|
- selectMusicCollection.reloadData()
|
|
|
|
|
|
+// if music.musicId != currentPlayingInVideoData?.musicId{
|
|
|
|
+ playStuckPointMusic(itemData:music)
|
|
|
|
+// }else{
|
|
|
|
+// avPlayer.pause()
|
|
|
|
+// }
|
|
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 music.musicId != currentPlayingInVideoData?.musicId{
|
|
|
|
|
|
+// if music.musicId != currentPlayingInVideoData?.musicId{
|
|
// BFLog(1, message: "预览:\(music.musicName) 当前:\(currentPlayingInVideoData?.musicName)")
|
|
// BFLog(1, message: "预览:\(music.musicName) 当前:\(currentPlayingInVideoData?.musicName)")
|
|
- if didSelectItemHandle != nil {
|
|
|
|
- didSelectItemHandle!(music.voiceStatue)
|
|
|
|
- }
|
|
|
|
|
|
+// }
|
|
|
|
+ if didSelectItemHandle != nil {
|
|
|
|
+ didSelectItemHandle!(music.voiceStatue)
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ selectMusicCollection.reloadData()
|
|
|
|
+
|
|
|
|
|
|
}else{
|
|
}else{
|
|
//停止分类列表的滑动。防止切换分类时 crash
|
|
//停止分类列表的滑动。防止切换分类时 crash
|
|
@@ -443,7 +458,7 @@ extension PQSelecteMusicView: UICollectionViewDelegate, UICollectionViewDataSour
|
|
|
|
|
|
func collectionView(_ collectionView: UICollectionView, willDisplay _: UICollectionViewCell, forItemAt indexPath: IndexPath) {
|
|
func collectionView(_ collectionView: UICollectionView, willDisplay _: UICollectionViewCell, forItemAt indexPath: IndexPath) {
|
|
|
|
|
|
- if (collectionView == selectMusicCollection ){
|
|
|
|
|
|
+ if (collectionView == selectMusicCollection && musicDatas.count > indexPath.item ){
|
|
let music = musicDatas[indexPath.item]
|
|
let music = musicDatas[indexPath.item]
|
|
|
|
|
|
PQEventTrackViewModel.baseReportUpload(businessType: .bt_buttonView, objectType: .ot_shanyinApp_musicVideoPreview_musicView, pageSource: .sp_shanyinApp_main, extParams: ["musicName":music.musicName ?? "" ,"musicId":music.musicId ?? ""], remindmsg: "")
|
|
PQEventTrackViewModel.baseReportUpload(businessType: .bt_buttonView, objectType: .ot_shanyinApp_musicVideoPreview_musicView, pageSource: .sp_shanyinApp_main, extParams: ["musicName":music.musicName ?? "" ,"musicId":music.musicId ?? ""], remindmsg: "")
|