| | |
| | | private var label_name:UILabel! |
| | | private var btn_handle:UIButton! |
| | | private var btn_handleClose:UIButton! |
| | | private var audioPlayer:AudioPlayer! |
| | | private(set) var audioPlayer:AudioPlayer! |
| | | private var isAniLoop:Bool = false |
| | | private var meditationModel:MeditationModel?{ |
| | | didSet{ |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | static func hidden(){ |
| | | if let tabBarVC = JQ_currentViewController().navigationController?.tabBarController as? BaseTabBarVC{ |
| | | if let vc = tabBarVC.children.filter({$0 is PayMusicVC}).first{ |
| | | AudioPlayer.destroy() |
| | | vc.view.removeFromSuperview() |
| | | vc.removeFromParent() |
| | | } |
| | | } |
| | | } |
| | | |
| | | @objc func showDetailAction(){ |
| | | if let id = meditationModel?.id{ |
| | |
| | | self.playIndex = firstPlayIndex |
| | | self.meditationModel = model |
| | | |
| | | let urls = model.backgroundUrl.components(separatedBy: ",").map { str in |
| | | return URL(string: str)! |
| | | } |
| | | let urls = model.meditationMusicList.map { url in |
| | | return URL(string: url)! |
| | | } |
| | | |
| | | if urls.count == 0{ |
| | | alertError(msg: "数据获取失败");return |
| | | } |
| | | |
| | | let masterUrl = URL(string: model.tutorAudioUrl) |
| | | |
| | |
| | | |
| | | |
| | | if loadTime >= totalTime{ |
| | | if weakSelf.playIndex <= urls.count - 1{ |
| | | if weakSelf.playIndex < urls.count - 1{ |
| | | weakSelf.next() |
| | | weakSelf.delegate?.playState(.next) |
| | | }else{ |
| | | weakSelf.delegate?.playState(.end) |
| | | PayMusicVC.hidden() |
| | | MPNowPlayingInfoCenter.default().nowPlayingInfo = nil |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | func next(){ |
| | | playIndex += 1 |
| | | if UserDefaultSettingViewModel.getSetting()?.playModel == .line{ |
| | | playIndex += 1 |
| | | } |
| | | |
| | | let index = min((urls.count - 1), playIndex) |
| | | bgmPlayer?.replaceCurrentItem(with: AVPlayerItem(url: urls[index])) |
| | | bgmPlayer?.play() |
| | |
| | | if newTimes <= 0{ |
| | | weakSelf.times.accept(nil) |
| | | weakSelf.stopTimer() |
| | | weakSelf.bgmPlayer?.pause() |
| | | weakSelf.masterPlayer?.pause() |
| | | weakSelf.scenePlayer?.pause() |
| | | MPNowPlayingInfoCenter.default().nowPlayingInfo = nil |
| | | AudioPlayer.destroy() |
| | | PayMusicVC.hidden() |
| | | }else{ |
| | | weakSelf.times.accept(newTimes) |
| | | } |