杨锴
2024-10-25 098286ed0313b1d3f1141113b371f8b17b8b26b5
XQMuse/Root/PayMusicView/PayMusicVC.swift
@@ -29,7 +29,7 @@
            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{
@@ -123,6 +123,16 @@
                                    }
                        }
            }
    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{
@@ -222,9 +232,13 @@
                        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)
@@ -255,11 +269,13 @@
                                    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
                                                }
                                    }
@@ -330,7 +346,10 @@
            }
            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()
@@ -417,6 +436,12 @@
                                    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)
                                    }