| | |
| | | |
| | | private var collect_bitem:UIBarButtonItem! |
| | | private var audioPlayer:AudioPlayer = AudioPlayer.getSharedInstance() |
| | | private var id:Int! |
| | | private var timeLook:Int = 0 //观看时间记录 |
| | | private var settingViewModel = UserDefaultSettingViewModel.getSetting() |
| | | |
| | |
| | | private var totalInterval:TimeInterval = 0 |
| | | |
| | | private var model:MeditationModel? |
| | | |
| | | // init(id:Int) { |
| | | // super.init(nibName: nil, bundle: nil) |
| | | // self.id = id |
| | | // } |
| | | |
| | | init(model:MeditationModel) { |
| | | super.init(nibName: nil, bundle: nil) |
| | |
| | | self.collect_bitem.image = m.favorite == .yes ? UIImage(named: "btn_collect_1_s"):UIImage(named: "btn_collect_1") |
| | | self.collect_bitem.tintColor = m.favorite == .yes ? UIColor(hexString: "fe5b60"):.white |
| | | self.img_background.sd_setImage(with: URL(string: m.backgroundUrl.jq_urlEncoded())) |
| | | |
| | | |
| | | if audioPlayer.meditationModel?.id == m.id{ |
| | | audioPlayer.delegate = self |
| | | let value = ((audioPlayer.bgmPlayer?.currentTime().seconds)! / 100.0) * (audioPlayer.bgmPlayer?.currentItem?.duration.seconds)! |
| | | if self.audioPlayer.bgmPlayer?.timeControlStatus == .paused{ |
| | | self.audioPlayer.setBGMRate(value: value) |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | @IBAction func playAction(_ sender: UIButton) { |
| | | sender.isSelected = !sender.isSelected |
| | | showHUD() |
| | | if let m = model{ |
| | | if sender.isSelected{ |
| | | if audioPlayer.meditationModel != nil{ |
| | | if audioPlayer.meditationModel?.id != m.id{ |
| | | audioPlayer.playBGMAt(firstPlayIndex: 0, model: m, delegate: self,coverImage: img_background.image) |
| | | PayMusicVC.updateStatus(.playing) |
| | | }else{ |
| | | audioPlayer.bgmPlayer?.play() |
| | | audioPlayer.masterPlayer?.play() |
| | | PayMusicVC.updateStatus(.playing) |
| | | } |
| | | |
| | | }else{ |
| | | audioPlayer.playBGMAt(firstPlayIndex: 0, model: m, delegate: self,coverImage: img_background.image) |
| | | PayMusicVC.updateStatus(.playing) |
| | | } |
| | | }else{ |
| | | audioPlayer.bgmPlayer?.pause() |
| | | audioPlayer.masterPlayer?.pause() |
| | | PayMusicVC.updateStatus(.pause) |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | @objc func collectionAction(){ |
| | | Services.meditationFavorite(id: id).subscribe(onNext: {data in |
| | | guard let id = model?.id else {return} |
| | | Services.meditationFavorite(id: id).subscribe(onNext: {data in |
| | | self.model?.favorite.troggle() |
| | | if self.model?.favorite == .yes{ |
| | | alertSuccess(msg: "收藏成功") |
| | |
| | | |
| | | func playState(_ state:PlayMusicState){ |
| | | print("music:当前状态:\(state)") |
| | | hiddenHUD() |
| | | |
| | | guard audioPlayer.meditationModel?.id == model?.id else {return} |
| | | |
| | | btn_play.isSelected = self.audioPlayer.bgmPlayer?.timeControlStatus == .playing |
| | | |
| | | switch state { |
| | | case .playing: |
| | | PayMusicVC.show(model: model!) |
| | | if btn_play.isHidden == false {btn_play.isHidden = true} |
| | | hiddenHUD() |
| | | case .paurse:btn_play.isHidden = false |
| | | case .paurse:break |
| | | case .end:break |
| | | case .next:break |
| | | } |