下载,收藏

This commit is contained in:
忆海16 2024-05-21 15:33:40 +08:00
parent 97297c7c55
commit e1f39fe1f7
6 changed files with 82 additions and 45 deletions

View File

@ -1455,7 +1455,7 @@
CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1.2; CURRENT_PROJECT_VERSION = 1.2;
DEVELOPMENT_TEAM = T93S37G27F; DEVELOPMENT_TEAM = 6HWQW9JC74;
ENABLE_USER_SCRIPT_SANDBOXING = NO; ENABLE_USER_SCRIPT_SANDBOXING = NO;
GENERATE_INFOPLIST_FILE = YES; GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = MusicPlayer/Info.plist; INFOPLIST_FILE = MusicPlayer/Info.plist;
@ -1493,7 +1493,7 @@
CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1.2; CURRENT_PROJECT_VERSION = 1.2;
DEVELOPMENT_TEAM = T93S37G27F; DEVELOPMENT_TEAM = 6HWQW9JC74;
ENABLE_USER_SCRIPT_SANDBOXING = NO; ENABLE_USER_SCRIPT_SANDBOXING = NO;
GENERATE_INFOPLIST_FILE = YES; GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = MusicPlayer/Info.plist; INFOPLIST_FILE = MusicPlayer/Info.plist;

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="22757" systemVersion="23E224" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier=""> <model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="22757" systemVersion="23E214" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier="">
<entity name="MPPositive_CollectionArtistModel" representedClassName="MPPositive_CollectionArtistModel" syncable="YES" codeGenerationType="class"> <entity name="MPPositive_CollectionArtistModel" representedClassName="MPPositive_CollectionArtistModel" syncable="YES">
<attribute name="artistId" optional="YES" attributeType="String"/> <attribute name="artistId" optional="YES" attributeType="String"/>
<attribute name="coverImage" optional="YES" attributeType="URI"/> <attribute name="coverImage" optional="YES" attributeType="URI"/>
<attribute name="subtitle" optional="YES" attributeType="String"/> <attribute name="subtitle" optional="YES" attributeType="String"/>

View File

@ -19,4 +19,6 @@ class MPPositive_CollectionSongModel: NSManagedObject, MP_CoreDataManageableDele
@NSManaged var subtitle:String? @NSManaged var subtitle:String?
///VideoID ///VideoID
@NSManaged var videoId:String? @NSManaged var videoId:String?
} }

View File

@ -75,9 +75,11 @@ class MPPositive_SongViewModel: NSObject {
relatedId = song.relatedID relatedId = song.relatedID
} }
// //
isCollection = MPPositive_CollectionSongModel.fetch(.init(format: "videoId == %@", song.videoId)).count != 0
// //
isDlownd = MPPositive_DownloadItemModel.fetch(.init(format: "videoId==%i", "dsadasda")).count != 0 isDlownd = MPPositive_DownloadItemModel.fetch(.init(format: "videoId == %@", song.videoId)).count != 0
// //
if isPloading == false { if isPloading == false {
preloadAsset(resourceAsset) preloadAsset(resourceAsset)

View File

@ -307,9 +307,9 @@ class MPPositive_PlayerViewController: MPPositive_BaseViewController, UIViewCont
coverView.subtitleLabel.text = MP_PlayerManager.shared.loadPlayer.currentVideo?.subtitle coverView.subtitleLabel.text = MP_PlayerManager.shared.loadPlayer.currentVideo?.subtitle
lyricsView.titleLabel.text = MP_PlayerManager.shared.loadPlayer.currentVideo?.title lyricsView.titleLabel.text = MP_PlayerManager.shared.loadPlayer.currentVideo?.title
lyricsView.subtitleLabel.text = MP_PlayerManager.shared.loadPlayer.currentVideo?.subtitle lyricsView.subtitleLabel.text = MP_PlayerManager.shared.loadPlayer.currentVideo?.subtitle
lyricsView.lyricsLabel.text = MP_PlayerManager.shared.loadPlayer.currentVideo.lyrics ?? "No Lyrics" lyricsView.lyricsLabel.text = MP_PlayerManager.shared.loadPlayer.currentVideo?.lyrics ?? "No Lyrics"
coverView.loadBtn.isSelected = MP_PlayerManager.shared.loadPlayer.currentVideo?.isDlownd ?? false coverView.loadBtn.isSelected = MP_PlayerManager.shared.loadPlayer.currentVideo?.isDlownd ?? false
coverView.collectionSongBtn.isSelected = MP_PlayerManager.shared.loadPlayer.currentVideo.isCollection ?? false coverView.collectionSongBtn.isSelected = MP_PlayerManager.shared.loadPlayer.currentVideo?.isCollection ?? false
} }
//MARK: - //MARK: -
// //

View File

@ -6,6 +6,7 @@
// //
import UIKit import UIKit
import SVProgressHUD
//BView(View) //BView(View)
class MPPositive_PlayerCoverView: UIView { class MPPositive_PlayerCoverView: UIView {
//View //View
@ -148,10 +149,32 @@ class MPPositive_PlayerCoverView: UIView {
} }
// //
@objc private func collectionSwitchClick(_ sender:UIButton) { @objc private func collectionSwitchClick(_ sender:UIButton) {
if self.collectionSongBtn.isSelected == true{
self.collectionSongBtn.isSelected = false
if MP_PlayerManager.shared.loadPlayer.currentVideo != nil{
MPPositive_CollectionSongModel.fetch(.init(format: "videoId == %@", MP_PlayerManager.shared.loadPlayer.currentVideo.song.videoId)).forEach { i in
if i.videoId == MP_PlayerManager.shared.loadPlayer.currentVideo.song.videoId{
MPPositive_CollectionSongModel.delete(i)
}
}
}
}else{
self.collectionSongBtn.isSelected = true
if MP_PlayerManager.shared.loadPlayer.currentVideo != nil{
let item = MPPositive_CollectionSongModel.create()
item.title = MP_PlayerManager.shared.loadPlayer.currentVideo.title
item.videoId = MP_PlayerManager.shared.loadPlayer.currentVideo.song.videoId
item.subtitle = MP_PlayerManager.shared.loadPlayer.currentVideo.subtitle
item.coverImage = MP_PlayerManager.shared.loadPlayer.currentVideo.coverUrl
MPPositive_CollectionSongModel.save()
}
}
} }
// //
@objc private func loadActionClick(_ sender:UIButton) { @objc private func loadActionClick(_ sender:UIButton) {
if MP_PlayerManager.shared.loadPlayer.currentVideo?.isDlownd == false{
// //
addCircularProgressBar(over: sender) addCircularProgressBar(over: sender)
@ -189,11 +212,21 @@ class MPPositive_PlayerCoverView: UIView {
case .failure(let error): case .failure(let error):
print("Download failed with error: \(error)") print("Download failed with error: \(error)")
self?.loadView.removeFromSuperview() self?.loadView.removeFromSuperview()
DispatchQueue.main.async {
self?.loadBtn.setBackgroundImage(UIImage(named: "Song_Unload'logo"), for: .normal)
self?.loadBtn.setImage(UIImage(named: ""), for: .normal)
}
SVProgressHUD.showInfo(withStatus: "下载超时请重新下载")
DispatchQueue.main.asyncAfter(deadline: .now() + 1.5) {
SVProgressHUD.dismiss()
}
} }
}) })
} }
} }
} }
}
// //
private func addCircularProgressBar(over button: UIButton) { private func addCircularProgressBar(over button: UIButton) {
loadView.removeFromSuperview() // loadView.removeFromSuperview() //