浏览代码

点击使用后暂停播放

jsonwang 3 年之前
父节点
当前提交
06fdd46b92
共有 1 个文件被更改,包括 7 次插入7 次删除
  1. 7 7
      BFFramework/Classes/Stuckpoint/View/PQSelecteMusicView.swift

+ 7 - 7
BFFramework/Classes/Stuckpoint/View/PQSelecteMusicView.swift

@@ -34,8 +34,10 @@ class PQSelecteMusicView: UIView {
         PQNotification.addObserver(forName: .AVPlayerItemDidPlayToEndTime, object: avPlayer.currentItem, queue: .main) { [weak self] notify in
             BFLog(message: "AVPlayerItemDidPlayToEndTime = \(notify)")
             avPlayer.seek(to: CMTime(value: CMTimeValue((self?.currentPlayData?.startTime ?? 0) * 1000), timescale: CMTimeScale(playerTimescale)))
-//            avPlayer.play()
-//            self?.playStuckPointMusic(itemData: nil)
+ 
+
+            self?.currentPlayData?.isPlaying = false
+            self?.selectMusicCollection.reloadData()
         }
         PQNotification.addObserver(forName: .AVPlayerItemNewErrorLogEntry, object: avPlayer.currentItem, queue: .main) { notify in
             BFLog(message: "AVPlayerItemNewErrorLogEntry = \(notify)")
@@ -214,8 +216,8 @@ class PQSelecteMusicView: UIView {
     
     //暂停播放音乐 并刷新 UI
     func pausePlayer() {
-        
-        playStuckPointMusic(itemData: currentPlayData)
+        avPlayer.pause()
+        currentPlayData?.isPlaying = false
         selectMusicCollection.reloadData()
     }
    
@@ -258,9 +260,7 @@ extension PQSelecteMusicView: UICollectionViewDelegate, UICollectionViewDataSour
             cell.btnClickHandle = { [weak self] sender, bgmData in
                 
                 //暂停播放音乐
-                self?.musicDatas[indexPath.item].isSelected = true
-                self?.playStuckPointMusic(itemData:  self?.musicDatas[indexPath.item])
-                self?.selectMusicCollection.reloadData()
+                self?.pausePlayer()
                 
                 if self?.btnClickHandle != nil {
                     self?.btnClickHandle!(sender, bgmData)