|
@@ -98,6 +98,43 @@ 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,
|
|
|
+ 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
|
|
|
+
|
|
|
+ let video = self.videos[indexPath.row]
|
|
|
+ /// 如果删除视频为当前播放视频,那么minibar 要初始化
|
|
|
+ if video.videoId == PlayerManager.shared.currentVideo?.videoId {
|
|
|
+ TSVideoOperator.shared.playerViewModel.clearCurrenVideo()
|
|
|
+ }
|
|
|
+ /// 歌单也要删除
|
|
|
+ PlayerManager.shared.player?.playControl.viewModel.currentVideos.removeAll {
|
|
|
+ $0.videoId == video.videoId
|
|
|
+ }
|
|
|
+
|
|
|
+ TSVideoOperator.shared.dataManager.deleteVideo(video: video) { _ in
|
|
|
+ self.requestData()
|
|
|
+ }
|
|
|
+
|
|
|
+ }))
|
|
|
+ PlayerManager.shared.rootVc?.present(ac, animated: true)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/// 加入选中列表
|
|
|
/// - Parameter video: video
|
|
|
func addToSelectedList(video: TSVideo) {
|