Forráskód Böngészése

feat:删除音乐在线模块

kailen 2 hónapja
szülő
commit
4d28e5124c

+ 1 - 1
Podfile

@@ -19,7 +19,7 @@ target 'TSLiveWallpaper' do
   pod 'TZImagePickerController'
   pod 'MarqueeLabel'
   pod 'MJRefresh'
-  pod 'TSVideoKit', :git => 'https://gitee.com/WanlanNeel/tsvideo-kit.git', :branch => 'feature/mini'
+  pod 'TSVideoKit', :git => 'https://gitee.com/WanlanNeel/tsvideo-kit.git', :branch => 'feature/local'
   pod "IJKMediaFramework", :podspec => 'https://github.com/debugly/ijkplayer/releases/download/k0.8.9/IJKMediaFramework.spec.json'
   pod 'KLExtension',:git=>"https://gitee.com/WanlanNeel/klextension.git"
   pod 'KLTips',:git=>"https://gitee.com/WanlanNeel/kltips.git"

+ 4 - 4
Podfile.lock

@@ -120,7 +120,7 @@ DEPENDENCIES:
   - ObjectMapper (= 4.2)
   - SnapKit
   - SVProgressHUD
-  - TSVideoKit (from `https://gitee.com/WanlanNeel/tsvideo-kit.git`, branch `feature/mini`)
+  - TSVideoKit (from `https://gitee.com/WanlanNeel/tsvideo-kit.git`, branch `feature/local`)
   - TYCyclePagerView
   - TZImagePickerController
 
@@ -152,7 +152,7 @@ EXTERNAL SOURCES:
   KLTips:
     :git: https://gitee.com/WanlanNeel/kltips.git
   TSVideoKit:
-    :branch: feature/mini
+    :branch: feature/local
     :git: https://gitee.com/WanlanNeel/tsvideo-kit.git
 
 CHECKOUT OPTIONS:
@@ -163,7 +163,7 @@ CHECKOUT OPTIONS:
     :commit: dc38e277b3d62f753ce6c73ec62c0f8ae29c1b36
     :git: https://gitee.com/WanlanNeel/kltips.git
   TSVideoKit:
-    :commit: c67bc820c784aa480f7de9b7ae302f5834b67ce7
+    :commit: 5ad45b75e2335442ec5633a5a614e45ac2f9fb3a
     :git: https://gitee.com/WanlanNeel/tsvideo-kit.git
 
 SPEC CHECKSUMS:
@@ -189,6 +189,6 @@ SPEC CHECKSUMS:
   TZImagePickerController: d084a7b97c82d387e7669dd86dc9a9057500aacf
   YYModel: 2a7fdd96aaa4b86a824e26d0c517de8928c04b30
 
-PODFILE CHECKSUM: 07b13e829723b93a980ec99e475f9251e550cf08
+PODFILE CHECKSUM: c7bc029bbc53876c8dd3936e0465b5ec7e834593
 
 COCOAPODS: 1.16.2

+ 3 - 78
TSLiveWallpaper/Business/TSMusic/Detail/Controller/PlayDetailViewController.swift

@@ -41,7 +41,6 @@ class PlayDetailViewController: LWBGViewController {
 
     lazy var topView: PlayDetailTopView = PlayDetailTopView()
     lazy var controlView: PlayDetailControlView = PlayDetailControlView()
-    var downloader: NewChunkDownloader?
     private var timer: Timer?
     private var cancellable: [AnyCancellable] = []
     private var downloaderCancellable: [AnyCancellable] = []
@@ -72,7 +71,6 @@ class PlayDetailViewController: LWBGViewController {
     override func addNotifaction() {
         super.addNotifaction()
         addPlayNotifaction()
-        addTaskNotifaction()
         addSleepNotifacion()
     }
 
@@ -92,14 +90,7 @@ class PlayDetailViewController: LWBGViewController {
     }
 
     @objc func retryAudio(notify: Notification) {
-        if let videoId = notify.object as? String,
-           videoId == PlayerManager.shared.currentVideo?.videoId {
-            TSNewDownloadManager.shared.retryDownload(videoId: videoId, isAudio: true) { [weak self] downloader in
-                guard let self = self else { return }
-                self.downloader = downloader
-                self.updateDownloader(id: videoId)
-            }
-        }
+      
     }
 
     func addPlayNotifaction() {
@@ -132,7 +123,7 @@ class PlayDetailViewController: LWBGViewController {
 
             /// 即将播放的和正在播放的视频是同一个
             if newValue != nil &&
-                oldValue?.videoId == newValue?.videoId {
+                oldValue?.videoId == newValue?.videoId{
                 PlayerManager.shared.showPlayerViewController()
                 return
             }
@@ -140,7 +131,6 @@ class PlayDetailViewController: LWBGViewController {
             if let mVideo = newValue {
                 self.controlView.updateVideoInfo(video: mVideo)
                 PlayerManager.shared.miniBar.updateVideoInfo(video: mVideo, state: .pause)
-                self.updateDownloader(id: mVideo.videoId ?? "")
             } else {
                 self.controlView.resetVideoInfo()
                 self.controlView.resetProgress()
@@ -234,42 +224,7 @@ class PlayDetailViewController: LWBGViewController {
         }
     }
 
-    func addTaskNotifaction() {
-        // 单个完成回调
-        NotificationCenter.default.addObserver(self, selector: #selector(updateDownoloadStatus(notify:)), name: kGroupDownloadFinishNotifactionName, object: nil)
-    }
-
-    func updateDownloader(id: String) {
-        if let downloader = TSNewDownloadManager.shared.fetchDownloader(identifier: id) {
-            downloaderCancellable.removeAll()
-            self.downloader = downloader
-            downloader.$progress.receive(on: DispatchQueue.main).sink { [weak self] progress in
-                self?.controlView.downloadButton.progressView.set(progress: Double(progress))
-            }.store(in: &downloaderCancellable)
-
-            downloader.$downloadState.receive(on: DispatchQueue.main).sink { state in
-                self.controlView.setDownloadButtonStates(status: state)
-            }.store(in: &downloaderCancellable)
-        } else {
-            downloaderCancellable.removeAll()
-            downloader = nil
-            if let video = TSVideoOperator.shared.dataManager.fetchVideo(videoId: id) {
-                controlView.setDownloadButtonStates(status: video.videoStatus.asChunkDownloadStatus)
-            } else {
-                controlView.setDownloadButtonStates(status: .idle)
-            }
-        }
-    }
 
-    @objc func updateDownoloadStatus(notify: Notification) {
-        if let videoId = notify.object as? String,
-           let video = TSVideoOperator.shared.dataManager.fetchVideo(videoId: videoId),
-           let currentVideo = TSVideoOperator.shared.playerViewModel.currentVideo {
-            if videoId == currentVideo.videoId {
-                controlView.setDownloadButtonStates(status: video.videoStatus.asChunkDownloadStatus)
-            }
-        }
-    }
 
     @objc func showMoreOperation() {
         let vc = CWOperateViewController(types: [.like, .addPlaylist, .share, .deleteVideo])
@@ -457,37 +412,7 @@ extension PlayDetailViewController {
     }
 
     @objc func downloadButtonAction(sender: DownloadButton) {
-        if let video = TSVideoOperator.shared.playerViewModel.currentVideo,
-           let videoId = video.videoId {
-            switch sender.downloadState {
-            case .idle(isAnimate: false), .idle(isAnimate: true):
-                TSNewDownloadManager.shared.downloadVideo(videoId: videoId, isAudio: false) { [weak self] downloader in
-                    self?.downloader = downloader
-                    self?.updateDownloader(id: videoId)
-                }
-                break
-            case .pause:
-                TSNewDownloadManager.shared.resumeTask(id: videoId) { [weak self] downloader in
-                    self?.downloader = downloader
-                    self?.updateDownloader(id: videoId)
-                }
-
-            case .downloading:
-                TSNewDownloadManager.shared.pauseTask(id: videoId) { [weak self] downloader in
-                    self?.downloader = downloader
-                    self?.updateDownloader(id: videoId)
-                }
-
-            case .retry:
-                TSNewDownloadManager.shared.retryDownload(videoId: videoId, isAudio: false) { [weak self] downloader in
-                    self?.downloader = downloader
-                    self?.updateDownloader(id: videoId)
-                }
-                break
-            default:
-                break
-            }
-        }
+      
     }
 
     // 调用这个方法来显示加载圈

+ 0 - 34
TSLiveWallpaper/Business/TSMusic/Detail/View/PlayDetailControlView.swift

@@ -128,7 +128,6 @@ class PlayDetailControlView: UIView {
         playlistButton.isHidden = video.videoStatus != .cached
         downloadButton.isHidden = video.videoStatus == .cached
         favouriteButton.isHidden = video.videoStatus != .cached
-        setDownloadButtonStates(status: video.videoStatus.asChunkDownloadStatus)
         downloadButton.progressView.set(progress: Double(video.progress))
         favouriteButton.isSelected = video.isFavorite
     }
@@ -150,39 +149,6 @@ class PlayDetailControlView: UIView {
         downloadButton.progressView.set(progress: Double(progress))
     }
 
-    public func setDownloadButtonStates(status: ChunkDownloadStatus) {
-        switch status {
-        case .idle, .cancel:
-            downloadButton.downloadState = .idle(isAnimate: false)
-            playlistButton.isHidden = true
-            downloadButton.isHidden = false
-            downloadButton.adTag.isHidden = PurchaseManager.default.isVip
-        case .prasing:
-            downloadButton.downloadState = .loading
-            playlistButton.isHidden = true
-            downloadButton.isHidden = false
-        case .praseSuccess:
-            break
-        case .downloading:
-            downloadButton.downloadState = .downloading
-            playlistButton.isHidden = true
-            downloadButton.isHidden = false
-        case .pause:
-            downloadButton.downloadState = .pause
-            playlistButton.isHidden = true
-            downloadButton.isHidden = false
-        case .failed:
-            downloadButton.downloadState = .retry
-            playlistButton.isHidden = true
-            downloadButton.isHidden = false
-        case .finished:
-            /// 完成,隐藏进度条,展示下载按钮,按钮状态设置为更多
-            downloadButton.downloadState = .idle(isAnimate: false)
-            playlistButton.isHidden = false
-            downloadButton.isHidden = true
-            favouriteButton.isHidden = false
-        }
-    }
 
     public func setDefaultDownloadStatus() {
         downloadButton.downloadState = .idle(isAnimate: false)

+ 0 - 8
TSLiveWallpaper/Business/TSMusic/List/Controller/MusicHomeContainerViewController.swift

@@ -48,14 +48,6 @@ class MusicHomeContainerViewController: LWBGViewController {
 
     override func viewDidLayoutSubviews() {
         super.viewDidLayoutSubviews()
-        print("TSConfiguration.isYs ===", TSConfiguration.isYs)
-        if UserDefaults.standard.string(forKey: "GuideKey") == nil, TSConfiguration.isYs {
-            view.addSubview(guideBubble)
-            view.bringSubviewToFront(guideBubble)
-            guideBubble.snp.makeConstraints { make in
-                make.edges.equalToSuperview()
-            }
-        }
     }
 
     func addTargets() {

+ 0 - 8
TSLiveWallpaper/Business/TSMusic/List/Controller/MusicPlaylistContainerViewController.swift

@@ -53,14 +53,6 @@ class MusicPlaylistContainerViewController: LWBGViewController {
 
     override func viewDidLayoutSubviews() {
         super.viewDidLayoutSubviews()
-        print("TSConfiguration.isYs ===", TSConfiguration.isYs)
-        if UserDefaults.standard.string(forKey: "GuideKey") == nil, TSConfiguration.isYs {
-            view.addSubview(guideBubble)
-            view.bringSubviewToFront(guideBubble)
-            guideBubble.snp.makeConstraints { make in
-                make.edges.equalToSuperview()
-            }
-        }
     }
 
     func addTargets() {

+ 1 - 67
TSLiveWallpaper/Business/TSMusic/List/Controller/SongListViewController+Target.swift

@@ -5,36 +5,11 @@
 //  Created by nkl on 2024/11/13.
 //
 
-//import ADManager
+// import ADManager
 import Foundation
 import TSVideoKit
 
 extension SongListViewController {
-   
-    // 长按手势处理
-    @objc func handleLongPress(_ gesture: UILongPressGestureRecognizer) {
-        let location = gesture.location(in: listView)
-
-        if gesture.state == .began {
-            if let indexPath = listView.indexPathForRow(at: location), indexPath.section == 0 {
-                let ac = UIAlertController(title: nil,
-                                           message: "Are you sure to delete".localized(), preferredStyle: .alert)
-                ac.addAction(UIAlertAction(title: "Cancel".localized(), style: .cancel))
-                ac.addAction(UIAlertAction(title: "Delete".localized(), style: .destructive, handler: { _ in
-                    if indexPath.row < self.viewModel.unFinishedVideo.count {
-                        let viewModel = self.viewModel.unFinishedVideo[indexPath.row]
-                        if let video = viewModel.dataVideo, let videoId = video.videoId {
-                            TSVideoOperator.shared.downloadManager.cancelTask(id: videoId) {
-                                self.viewModel.requestData()
-                            }
-                        }
-                    }
-                }))
-                present(ac, animated: true, completion: nil)
-            }
-        }
-    }
-
     func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
         if indexPath.section == 0 {
             guard let cell = cell as? SongDownloadCell, indexPath.row < viewModel.unFinishedVideo.count else {
@@ -44,47 +19,6 @@ extension SongListViewController {
             let viewModel = viewModel.unFinishedVideo[indexPath.row]
 
             cell.bindViewModel(viewModel: viewModel, isOnline: false)
-
-            cell.downloadStateChangeBlock = { [weak self] state in
-                guard let self = self else {
-                    return
-                }
-                switch state {
-                case .idle(isAnimate: false), .idle(isAnimate: true):
-//                    if PurchaseManager.default.isVip {
-                    viewModel.startDownload()
-//                    if !PurchaseManager.default.isVip {
-//                        ADManager.shared.showAd(scene: ADScene.downloadInsert, from: self)
-//                    }
-//                    } else {
-//                        let loading = ADLoadingViewController()
-//                        loading.adScene = .downloadReward
-//                        loading.finishedHandler = { finished in
-//                            if finished {
-//                                viewModel.startDownload()
-//                            }
-//                        }
-//                        present(loading, animated: false)
-//                    }
-                case .pause:
-                    viewModel.resumeDownload()
-                    break
-                case .done:
-                    if let videoModel = viewModel.dataVideo {
-//                        self.viewModel.showOperationViewController(video: videoModel)
-                    }
-                    break
-                case .downloading:
-                    viewModel.pauseDownload()
-                    break
-                case .retry:
-                    /// todo.kailen
-                    viewModel.retryDownload()
-                    break
-                case .loading:
-                    break
-                }
-            }
         }
     }
 }

+ 1 - 12
TSLiveWallpaper/Business/TSMusic/List/Controller/SongListViewController.swift

@@ -71,8 +71,6 @@ class SongListViewController: LWBGViewController {
         viewModel.requestData()
         addNotifaction()
 
-        let longPressGesture = UILongPressGestureRecognizer(target: self, action: #selector(handleLongPress(_:)))
-        listView.addGestureRecognizer(longPressGesture)
     }
 
     override func addNotifaction() {
@@ -179,16 +177,7 @@ class SongListViewController: LWBGViewController {
 extension SongListViewController: UITableViewDelegate {
     func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
         if indexPath.section == 0 {
-            if indexPath.row < viewModel.unFinishedVideo.count {
-                let vModel = viewModel.unFinishedVideo[indexPath.row]
-                switch vModel.state {
-                case .pause:
-                    vModel.resumeDownload()
-                default:
-                    THUD.toast("Downloading".localized())
-                    break
-                }
-            }
+
         } else {
             print("indexPath.row == \(indexPath.row) , count = \(viewModel.videos.count) ")
             if indexPath.row < viewModel.videos.count {

+ 0 - 67
TSLiveWallpaper/Business/TSMusic/List/View/SongDownloadCell.swift

@@ -66,29 +66,6 @@ class SongDownloadCell: UITableViewCell {
             videoId = video.videoId ?? ""
         }
 
-        /// 查找下载器
-        if let mDownloader = TSNewDownloadManager.shared.fetchDownloader(identifier: videoId) {
-            self.viewModel?.downloader = mDownloader
-        } else {
-            self.viewModel?.downloader = nil
-        }
-
-        /// 添加监听
-        self.viewModel?.$downloader
-            .compactMap { $0 }
-            .flatMap { $0.$progress }
-            .receive(on: DispatchQueue.main)
-            .sink { [weak self] progress in
-                self?.downloadBtn.progressView.set(progress: Double(progress))
-            }
-            .store(in: &cancellable)
-
-        self.viewModel?.downloader?.$downloadState
-            .receive(on: DispatchQueue.main)
-            .sink { [weak self] status in
-                self?.setDownloadButtonStates(status: status)
-            }
-            .store(in: &cancellable)
 
         self.viewModel?.$state.receive(on: DispatchQueue.main).sink(receiveValue: { [weak self] state in
             self?.downloadBtn.downloadState = state
@@ -105,7 +82,6 @@ class SongDownloadCell: UITableViewCell {
             iconView.kf.setImage(with: video.iconUrl, placeholder: UIImage(named: "ic_default"))
             // todo.kailen
             bgImageView.isHidden = PlayerManager.shared.currentVideo?.videoId != video.videoId
-            setDownloadButtonStates(status: .idle)
         }
     }
 
@@ -120,32 +96,6 @@ class SongDownloadCell: UITableViewCell {
         iconView.kf.setImage(with: video.iconUrl, placeholder: UIImage(named: "ic_default"))
         bgImageView.isHidden = PlayerManager.shared.currentVideo?.videoId != video.videoId
         downloadBtn.progressView.set(progress: Double(video.progress))
-        setDownloadButtonStates(status: video.videoStatus.asChunkDownloadStatus)
-    }
-
-    func setDownloadButtonStates(status: ChunkDownloadStatus) {
-        switch status {
-        case .idle, .cancel:
-            viewModel?.state = .idle(isAnimate: false)
-            downloadBtn.adTag.isHidden = PurchaseManager.default.isVip
-        case .prasing:
-            viewModel?.state = .loading
-            downloadBtn.adTag.isHidden = true
-        case .praseSuccess:
-            break
-        case .downloading:
-            viewModel?.state = .downloading
-            downloadBtn.adTag.isHidden = true
-        case .pause:
-            viewModel?.state = .pause
-            downloadBtn.adTag.isHidden = true
-        case .failed:
-            viewModel?.state = .retry
-            downloadBtn.adTag.isHidden = true
-        case .finished:
-            viewModel?.state = .done
-            downloadBtn.adTag.isHidden = true
-        }
     }
 
     func setDefaultProgress() {
@@ -224,20 +174,3 @@ class SongDownloadCell: UITableViewCell {
         fatalError("init(coder:) has not been implemented")
     }
 }
-
-extension TSVideoStatus {
-    var asChunkDownloadStatus: ChunkDownloadStatus {
-        switch self {
-        case .idle:
-            return .idle
-        case .running:
-            return .downloading
-        case .cached:
-            return .finished
-        case .pause:
-            return .pause
-        case .failed:
-            return .failed
-        }
-    }
-}

+ 0 - 36
TSLiveWallpaper/Business/TSMusic/List/ViewModel/SongDownloadCellViewModel.swift

@@ -11,7 +11,6 @@ import TSVideoKit
 
 class SongDownloadCellViewModel {
     @Published var state: DownloadButtonState = .idle(isAnimate: false)
-    @Published var downloader: NewChunkDownloader?
 
     var dataModel: VideoOnlineModel?
     var dataVideo: TSVideo?
@@ -22,39 +21,4 @@ class SongDownloadCellViewModel {
         self.dataModel = dataModel
         dataVideo = video
     }
-
-    func setDownloader(_ downloader: NewChunkDownloader) {
-        self.downloader = downloader
-    }
-
-    func startDownload() {
-        guard let videoId = dataModel?.videoId ?? dataVideo?.videoId else { return }
-        TSNewDownloadManager.shared.downloadVideo(videoId: videoId, isAudio: false) { [weak self] downloader in
-            self?.downloader = downloader
-            NotificationCenter.default.post(name: kDataChangedNotifactionName, object: nil)
-        }
-    }
-
-    func resumeDownload() {
-        guard let videoId = dataModel?.videoId ?? dataVideo?.videoId else { return }
-        TSNewDownloadManager.shared.resumeTask(id: videoId) { [weak self] downloader in
-            self?.downloader = downloader
-            NotificationCenter.default.post(name: kDataChangedNotifactionName, object: nil)
-        }
-    }
-
-    func pauseDownload() {
-        guard let videoId = dataModel?.videoId ?? dataVideo?.videoId else { return }
-        TSNewDownloadManager.shared.pauseTask(id: videoId) { _ in
-            NotificationCenter.default.post(name: kDataChangedNotifactionName, object: nil)
-        }
-    }
-
-    func retryDownload(isAudio: Bool = false) {
-        guard let videoId = dataModel?.videoId ?? dataVideo?.videoId else { return }
-        TSNewDownloadManager.shared.retryDownload(videoId: videoId, isAudio: isAudio) { [weak self] downloader in
-            self?.downloader = downloader
-            NotificationCenter.default.post(name: kDataChangedNotifactionName, object: nil)
-        }
-    }
 }

+ 1 - 8
TSLiveWallpaper/Business/TSMusic/List/ViewModel/SongListViewModel.swift

@@ -100,14 +100,7 @@ extension SongListViewModel: UITableViewDataSource {
     
     func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) {
         if indexPath.section == 0 {
-            if indexPath.row < unFinishedVideo.count {
-                let viewModel = unFinishedVideo[indexPath.row]
-                if let video = viewModel.dataVideo, let videoId = video.videoId {
-                    TSVideoOperator.shared.downloadManager.cancelTask(id: videoId) {
-                        self.requestData()
-                    }
-                }
-            }
+//         
         } else {
             if indexPath.row < videos.count {
                 let ac = UIAlertController(title: nil,