| | |
| | | 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{ |
| | |
| | | } |
| | | |
| | | }.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(){ |
| | |
| | | } |
| | | |
| | | @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() |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | 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) |
| | | |