|  | @@ -22,6 +22,7 @@ class PQSelecteMusicView: UIView {
 | 
											
												
													
														|  |      var currentPlayData: PQVoiceModel?
 |  |      var currentPlayData: PQVoiceModel?
 | 
											
												
													
														|  |      // 当前播放的音频
 |  |      // 当前播放的音频
 | 
											
												
													
														|  |      var playerItem: AVPlayerItem?
 |  |      var playerItem: AVPlayerItem?
 | 
											
												
													
														|  | 
 |  | +    var playerItemHavObserver: Bool = false
 | 
											
												
													
														|  |      
 |  |      
 | 
											
												
													
														|  |      // 按钮点击的回调
 |  |      // 按钮点击的回调
 | 
											
												
													
														|  |      var btnClickHandle: ((_ sender: UIButton, _ bgmData: Any?) -> Void)?
 |  |      var btnClickHandle: ((_ sender: UIButton, _ bgmData: Any?) -> Void)?
 | 
											
										
											
												
													
														|  | @@ -118,8 +119,10 @@ class PQSelecteMusicView: UIView {
 | 
											
												
													
														|  |      deinit {
 |  |      deinit {
 | 
											
												
													
														|  |          PQNotification.removeObserver(self)
 |  |          PQNotification.removeObserver(self)
 | 
											
												
													
														|  |          PQNotification.removeObserver(self.avPlayer.currentItem as Any)
 |  |          PQNotification.removeObserver(self.avPlayer.currentItem as Any)
 | 
											
												
													
														|  | -        avPlayer.currentItem?.removeObserver(self, forKeyPath: "status")
 |  | 
 | 
											
												
													
														|  | -        avPlayer.currentItem?.removeObserver(self, forKeyPath: "error")
 |  | 
 | 
											
												
													
														|  | 
 |  | +        if playerItemHavObserver {
 | 
											
												
													
														|  | 
 |  | +            avPlayer.currentItem?.removeObserver(self, forKeyPath: "status")
 | 
											
												
													
														|  | 
 |  | +            avPlayer.currentItem?.removeObserver(self, forKeyPath: "error")
 | 
											
												
													
														|  | 
 |  | +        }
 | 
											
												
													
														|  |          avPlayer.pause()
 |  |          avPlayer.pause()
 | 
											
												
													
														|  |          avPlayer.replaceCurrentItem(with: nil)
 |  |          avPlayer.replaceCurrentItem(with: nil)
 | 
											
												
													
														|  |          playerItem = nil
 |  |          playerItem = nil
 | 
											
										
											
												
													
														|  | @@ -275,9 +278,12 @@ class PQSelecteMusicView: UIView {
 | 
											
												
													
														|  |                  return
 |  |                  return
 | 
											
												
													
														|  |              }
 |  |              }
 | 
											
												
													
														|  |              avPlayer.pause()
 |  |              avPlayer.pause()
 | 
											
												
													
														|  | -            playerItem?.removeObserver(self, forKeyPath: "status")
 |  | 
 | 
											
												
													
														|  | -            playerItem?.removeObserver(self, forKeyPath: "error")
 |  | 
 | 
											
												
													
														|  | -            
 |  | 
 | 
											
												
													
														|  | 
 |  | +            if playerItemHavObserver {
 | 
											
												
													
														|  | 
 |  | +                playerItem?.removeObserver(self, forKeyPath: "status")
 | 
											
												
													
														|  | 
 |  | +                playerItem?.removeObserver(self, forKeyPath: "error")
 | 
											
												
													
														|  | 
 |  | +                playerItemHavObserver = false
 | 
											
												
													
														|  | 
 |  | +            }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |              if itemData!.musicId == currentPlayingInVideoData?.musicId {
 |  |              if itemData!.musicId == currentPlayingInVideoData?.musicId {
 | 
											
												
													
														|  |                  itemData?.voiceStatue = .isSelected
 |  |                  itemData?.voiceStatue = .isSelected
 | 
											
												
													
														|  |                  currentPlayData = itemData
 |  |                  currentPlayData = itemData
 | 
											
										
											
												
													
														|  | @@ -292,6 +298,7 @@ class PQSelecteMusicView: UIView {
 | 
											
												
													
														|  |              avPlayer.replaceCurrentItem(with: playerItem)
 |  |              avPlayer.replaceCurrentItem(with: playerItem)
 | 
											
												
													
														|  |              playerItem?.addObserver(self, forKeyPath: "status", options: .new, context: nil)
 |  |              playerItem?.addObserver(self, forKeyPath: "status", options: .new, context: nil)
 | 
											
												
													
														|  |              playerItem?.addObserver(self, forKeyPath: "error", options: .new, context: nil)
 |  |              playerItem?.addObserver(self, forKeyPath: "error", options: .new, context: nil)
 | 
											
												
													
														|  | 
 |  | +            playerItemHavObserver = true
 | 
											
												
													
														|  |              avPlayer.seek(to: CMTime(value: CMTimeValue((itemData?.startTime ?? 0) * playerTimescale), timescale: CMTimeScale(playerTimescale)))
 |  |              avPlayer.seek(to: CMTime(value: CMTimeValue((itemData?.startTime ?? 0) * playerTimescale), timescale: CMTimeScale(playerTimescale)))
 | 
											
												
													
														|  |              avPlayer.play()
 |  |              avPlayer.play()
 | 
											
												
													
														|  |              itemData?.voiceStatue = .isPlaying
 |  |              itemData?.voiceStatue = .isPlaying
 |