杨锴
2024-11-06 63f7ed967433acee3ae8764c7a077e15c29c41f2
XQMuse/Root/Home/VC/HomeItemDetailVC.swift
@@ -31,6 +31,11 @@
            private var id:Int!
    private var timeLook:Int = 0 //观看时间记录
            private var settingViewModel = UserDefaultSettingViewModel.getSetting()
    private var currentInterval:TimeInterval = 0
    private var totalInterval:TimeInterval = 0
            private var model:MeditationModel?{
                        didSet{
                                    if let m = model{
@@ -140,6 +145,13 @@
                                    }
                        }.disposed(by: disposeBag)
        slider_voice.rx.value.changed.subscribe(onNext: {[weak self] v in
            guard let weakSelf = self else { return }
            let value = (v.double / 100.0) * weakSelf.totalInterval
            self?.audioPlayer.setBGMRate(value: value)
        }).disposed(by: disposeBag)
            }
            private func startMiniRunloop(){
@@ -159,8 +171,14 @@
            }
            @IBAction func playAction(_ sender: UIButton) {
        sender.isSelected = !sender.isSelected
                        if let m = model{
                                    audioPlayer.playBGMAt(firstPlayIndex: 0, model: m, delegate: self)
            if sender.isSelected{
                audioPlayer.playBGMAt(firstPlayIndex: 0, model: m, delegate: self,coverImage: img_background.image)
            }else{
                audioPlayer.bgmPlayer?.pause()
            }
                        }
            }
@@ -281,11 +299,18 @@
                        guard !totalInterval.isNaN else {return}
                        guard !currentInterval.isNaN else {return}
        self.currentInterval = currentInterval
        self.totalInterval = totalInterval
        timeLook += 1
                        let v = currentInterval / totalInterval * 100
                        print("music:当前时间:\(currentInterval) ---- \(totalInterval) -- \(v)%")
                        self.slider_voice.value = Float(v)
        if !self.slider_voice.isTracking{
            self.slider_voice.value = Float(v)
        }
                        let current = Date.jq_formateToTime_tuple(Int(currentInterval))
                        label_currentTime.text = String(format: "%02ld:%02ld", current.hour * 60 + current.minute,current.second)