| | |
| | | |
| | | @objc func showDetailAction(){ |
| | | if let id = meditationModel?.id{ |
| | | |
| | | Services.getMeditationDetail(id: id).subscribe(onNext: {[weak self]data in |
| | | guard let weakSelf = self else { return } |
| | | if let m = data.data{ |
| | |
| | | self.startRunloopAni() |
| | | PayMusicVC.updateStatus(.playing) |
| | | } |
| | | DispatchQueue.main.asyncAfter(delay: 0.4) { |
| | | NotificationCenter.default.post(name: ReloadData_Noti, object: nil, userInfo: nil) |
| | | } |
| | | } |
| | | |
| | | @objc func closeAction(_ btn:UIButton){ |
| | |
| | | if UserDefaultSettingViewModel.getSetting()?.bgm != nil{ |
| | | AudioPlayer.getSharedInstance().playSceneAt(UserDefaultSettingViewModel.getSetting()!.bgm!.audioFile) |
| | | } |
| | | |
| | | DispatchQueue.main.asyncAfter(delay: 0.4) { |
| | | NotificationCenter.default.post(name: ReloadData_Noti, object: nil, userInfo: nil) |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | private var timer:Timer? |
| | | private(set) var times = BehaviorRelay<Int?>(value: nil) //倒计时定时器 |
| | | private static var _sharedInstance: AudioPlayer? |
| | | private(set) var meditationModel:MeditationModel? //疗愈音频 |
| | | var meditationModel:MeditationModel? //疗愈音频 |
| | | var lisenMuseTime:Int = 0 //听疗愈时间记录 |
| | | |
| | | weak var delegate:PayMusicDelegate? |
| | |
| | | |
| | | autoreleasepool{[unowned self] () in |
| | | for url in urls { |
| | | self.checkCacheAudio(from: url) {[unowned self] _, url in |
| | | self.urls.append(url) |
| | | self.checkCacheAudio(from: url) {[unowned self] _, url in |
| | | self.urls.append(url) |
| | | } |
| | | } |
| | | self.bgmPlayer = AVPlayer(url: self.urls[firstPlayIndex]) |
| | |
| | | |
| | | if let m = weakSelf.meditationModel{ |
| | | var dic = [String:Any]() |
| | | dic[MPMediaItemPropertyTitle] = m |
| | | dic[MPMediaItemPropertyTitle] = m.meditationTitle |
| | | dic[MPMediaItemPropertyArtist] = "泉疗愈" |
| | | dic[MPMediaItemPropertyDiscNumber] = 1 |
| | | dic[MPNowPlayingInfoPropertyElapsedPlaybackTime] = loadTime |
| | |
| | | } |
| | | } |
| | | |
| | | self.bgmPlayer?.currentItem?.rx.observe(AVPlayerItem.Status.self,"status").subscribe(onNext: { _ in |
| | | self.bgmPlayer?.rx.observe(AVPlayer.TimeControlStatus.self,"timeControlStatus").subscribe(onNext: { state in |
| | | DispatchQueue.main.asyncAfter(delay: 1.0) { |
| | | if state == .paused{ |
| | | print("----》暂停") |
| | | PayMusicVC.updateStatus(.pause) |
| | | }else if state == .playing{ |
| | | print("----》播放") |
| | | PayMusicVC.updateStatus(.playing) |
| | | } |
| | | } |
| | | }).disposed(by: disposeBag) |
| | | |
| | | |
| | | |
| | | self.bgmPlayer?.currentItem?.rx.observe(AVPlayerItem.Status.self,"status").subscribe(onNext: { _ in |
| | | print("---MasterStatus1: \(self.masterPlayer?.status.rawValue ?? 0)") |
| | | print("---bgmStatus1: \(self.bgmPlayer?.status.rawValue ?? 0)") |
| | | if self.bgmPlayer?.status == .readyToPlay && self.masterPlayer?.status == .readyToPlay{ |
| | | self.bgmPlayer?.play() |
| | | self.masterPlayer?.play() |
| | |
| | | |
| | | self.masterPlayer?.currentItem?.rx.observe(AVPlayerItem.Status.self,"status").subscribe(onNext: { _ in |
| | | print("---MasterStatus: \(self.masterPlayer?.status.rawValue ?? 0)") |
| | | print("---bgmStatus: \(self.bgmPlayer?.status.rawValue ?? 0)") |
| | | if self.bgmPlayer?.status == .readyToPlay && self.masterPlayer?.status == .readyToPlay{ |
| | | self.bgmPlayer?.play() |
| | | self.masterPlayer?.play() |