1.2.2VIP问题修复版
@ -270,6 +270,9 @@
|
||||
CBDBDDF42C40D03F00767F0B /* MPPositive_SearchGrideCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = CBDBDDF32C40D03F00767F0B /* MPPositive_SearchGrideCollectionViewCell.swift */; };
|
||||
CBDBDDF62C40FFC600767F0B /* MPPositive_GrideMoodViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CBDBDDF52C40FFC600767F0B /* MPPositive_GrideMoodViewController.swift */; };
|
||||
CBDC4A292C61B88300960649 /* relax.offline.mp3.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = CBDC4A272C61B88300960649 /* relax.offline.mp3.xcdatamodeld */; };
|
||||
CBEC78BF2CA28FB700666A7F /* MPPositive_AddSongsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CBEC78BE2CA28FB700666A7F /* MPPositive_AddSongsViewController.swift */; };
|
||||
CBEC78C12CA2963100666A7F /* MPPositive_AddSongsShowView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CBEC78C02CA2963100666A7F /* MPPositive_AddSongsShowView.swift */; };
|
||||
CBEC78C32CA2A0CB00666A7F /* MPPositive_AddSongTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = CBEC78C22CA2A0CB00666A7F /* MPPositive_AddSongTableViewCell.swift */; };
|
||||
CBF3AEDA2C255B1200947AFC /* MPPositive_PlayListsShowTypeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CBF3AED92C255B1200947AFC /* MPPositive_PlayListsShowTypeView.swift */; };
|
||||
CBF769992C95678A00EF9B45 /* Devices.swift in Sources */ = {isa = PBXBuildFile; fileRef = CBF769982C95678A00EF9B45 /* Devices.swift */; };
|
||||
/* End PBXBuildFile section */
|
||||
@ -566,6 +569,9 @@
|
||||
CBDBDDF32C40D03F00767F0B /* MPPositive_SearchGrideCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MPPositive_SearchGrideCollectionViewCell.swift; sourceTree = "<group>"; };
|
||||
CBDBDDF52C40FFC600767F0B /* MPPositive_GrideMoodViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MPPositive_GrideMoodViewController.swift; sourceTree = "<group>"; };
|
||||
CBDC4A282C61B88300960649 /* MusicPlayer.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = MusicPlayer.xcdatamodel; sourceTree = "<group>"; };
|
||||
CBEC78BE2CA28FB700666A7F /* MPPositive_AddSongsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MPPositive_AddSongsViewController.swift; sourceTree = "<group>"; };
|
||||
CBEC78C02CA2963100666A7F /* MPPositive_AddSongsShowView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MPPositive_AddSongsShowView.swift; sourceTree = "<group>"; };
|
||||
CBEC78C22CA2A0CB00666A7F /* MPPositive_AddSongTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MPPositive_AddSongTableViewCell.swift; sourceTree = "<group>"; };
|
||||
CBF3AED92C255B1200947AFC /* MPPositive_PlayListsShowTypeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MPPositive_PlayListsShowTypeView.swift; sourceTree = "<group>"; };
|
||||
CBF769982C95678A00EF9B45 /* Devices.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Devices.swift; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
@ -921,6 +927,7 @@
|
||||
children = (
|
||||
CBAFCA662C0A10500054500E /* MPPositive_LibraryViewController.swift */,
|
||||
CB0033F32C294DBF00B18FD3 /* MPPositive_CustomPlayListViewController.swift */,
|
||||
CBEC78BE2CA28FB700666A7F /* MPPositive_AddSongsViewController.swift */,
|
||||
CB0033FB2C29753D00B18FD3 /* MPPositive_PlayListMoreViewController.swift */,
|
||||
CBCBA7D82C6DFD93004E5BEF /* MPPositive_SortTypeViewController.swift */,
|
||||
CB0033F72C29626900B18FD3 /* MPPositive_ChoosePlayListViewController.swift */,
|
||||
@ -994,6 +1001,8 @@
|
||||
CBF3AED92C255B1200947AFC /* MPPositive_PlayListsShowTypeView.swift */,
|
||||
CB0033F12C291C7700B18FD3 /* MPPositive_CollectionListsShowTypeView.swift */,
|
||||
CBDAC60D2C2BE1B6008B8D34 /* MPPositive_ChooseNewPlayListTableViewCell.swift */,
|
||||
CBEC78C02CA2963100666A7F /* MPPositive_AddSongsShowView.swift */,
|
||||
CBEC78C22CA2A0CB00666A7F /* MPPositive_AddSongTableViewCell.swift */,
|
||||
CB7FC5472C2AC25C00292A43 /* MPPositive_CenterListSearchView.swift */,
|
||||
CBAFCA7E2C0A10500054500E /* MPPositive_LibraryTableViewCell.swift */,
|
||||
CBAFCA7F2C0A10500054500E /* MPPositive_LoveArtistTableViewCell.swift */,
|
||||
@ -1541,6 +1550,7 @@
|
||||
CBDBDDF62C40FFC600767F0B /* MPPositive_GrideMoodViewController.swift in Sources */,
|
||||
CBAFCB932C0A10500054500E /* MPSideA_PlayerViewController.swift in Sources */,
|
||||
CBAFCB512C0A10500054500E /* MPPositive_SearchResultShowViewController.swift in Sources */,
|
||||
CBEC78C32CA2A0CB00666A7F /* MPPositive_AddSongTableViewCell.swift in Sources */,
|
||||
CBAFCB4C2C0A10500054500E /* MPPositive_ListShowViewController.swift in Sources */,
|
||||
CBAFCB682C0A10500054500E /* MPPositive_MusicItemShowTableViewCell.swift in Sources */,
|
||||
CBAFCB5B2C0A10500054500E /* MPPositive_ArtistShowCollectionViewCell.swift in Sources */,
|
||||
@ -1575,6 +1585,7 @@
|
||||
CBAFCB7E2C0A10500054500E /* MPSideA_TabBarController.swift in Sources */,
|
||||
CBAFCB1D2C0A10500054500E /* MPPositive_JsonPlayer.swift in Sources */,
|
||||
CBC1FB7C2C509B7300AC0633 /* MPPositive_LibraryViewModel.swift in Sources */,
|
||||
CBEC78C12CA2963100666A7F /* MPPositive_AddSongsShowView.swift in Sources */,
|
||||
CBAFCB602C0A10500054500E /* MPPositive_ArtistShowTypeView.swift in Sources */,
|
||||
CBAFCB6F2C0A10500054500E /* MPPositive_SearchResultPreviewShowView.swift in Sources */,
|
||||
CB0033F42C294DBF00B18FD3 /* MPPositive_CustomPlayListViewController.swift in Sources */,
|
||||
@ -1648,6 +1659,7 @@
|
||||
CBAFCB9B2C0A10500054500E /* MPSideA_CenterTableViewCell.swift in Sources */,
|
||||
CBC3F2B22C3E76160075DC74 /* MPPositive_AdItemModel.swift in Sources */,
|
||||
CBAFCB412C0A10500054500E /* MPPositive_BaseViewController.swift in Sources */,
|
||||
CBEC78BF2CA28FB700666A7F /* MPPositive_AddSongsViewController.swift in Sources */,
|
||||
CBCBA7D92C6DFD93004E5BEF /* MPPositive_SortTypeViewController.swift in Sources */,
|
||||
CBAFCB4E2C0A10500054500E /* MPPositive_PlayerListShowViewController.swift in Sources */,
|
||||
CBD1E19F2C57650F00DF20E5 /* MP_IAPManager.swift in Sources */,
|
||||
|
||||
@ -0,0 +1,22 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "complete@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "complete@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
BIN
relax.offline.mp3.music/Assets.xcassets/Positive/Center/Added_PlayList'logo.imageset/complete@2x.png
vendored
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
BIN
relax.offline.mp3.music/Assets.xcassets/Positive/Center/Added_PlayList'logo.imageset/complete@3x.png
vendored
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
22
relax.offline.mp3.music/Assets.xcassets/Positive/Center/New_AddSong'logo.imageset/Contents.json
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "add_btn@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "add_btn@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
BIN
relax.offline.mp3.music/Assets.xcassets/Positive/Center/New_AddSong'logo.imageset/add_btn@2x.png
vendored
Normal file
|
After Width: | Height: | Size: 1.0 KiB |
BIN
relax.offline.mp3.music/Assets.xcassets/Positive/Center/New_AddSong'logo.imageset/add_btn@3x.png
vendored
Normal file
|
After Width: | Height: | Size: 2.2 KiB |
@ -0,0 +1,22 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "add@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "add@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
BIN
relax.offline.mp3.music/Assets.xcassets/Positive/Center/UnAdd_PlayLists'logo.imageset/add@2x.png
vendored
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
relax.offline.mp3.music/Assets.xcassets/Positive/Center/UnAdd_PlayLists'logo.imageset/add@3x.png
vendored
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
@ -0,0 +1,22 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "Group_1597880767@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "Group_1597880767@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 642 B |
|
After Width: | Height: | Size: 1.1 KiB |
@ -0,0 +1,22 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "Group_1597880779@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "Group_1597880779@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 711 B |
|
After Width: | Height: | Size: 1.3 KiB |
@ -0,0 +1,22 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "Rectangle_161124246@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "Rectangle_161124246@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 38 KiB |
@ -78,6 +78,7 @@ class MP_LunchViewController: UIViewController {
|
||||
}
|
||||
override func viewWillDisappear(_ animated: Bool) {
|
||||
super.viewWillDisappear(animated)
|
||||
NotificationCenter.default.removeObserver(self)
|
||||
}
|
||||
|
||||
//计时器执行事件
|
||||
@ -132,15 +133,7 @@ class MP_LunchViewController: UIViewController {
|
||||
MPPositive_BrowseLoadViewModel.shared.reloadBrowseLists()
|
||||
}
|
||||
}
|
||||
MP_ADSimpleManager.shared.loadMoreAds()
|
||||
MP_ADSimpleManager.shared.showOpenAdIfAvailable(.ICE) { [weak self] (ad, isOpen, platform) in
|
||||
guard let self = self else {return}
|
||||
addValue = 3
|
||||
//将广告事件传递闭包赋值
|
||||
adShowBlock = {
|
||||
self.adPresent(ad: ad, isOpen: isOpen, platform: platform)
|
||||
}
|
||||
}
|
||||
loadAds()
|
||||
//进入过B面
|
||||
self.completionBlock = {
|
||||
//允许进入b面
|
||||
@ -170,16 +163,7 @@ class MP_LunchViewController: UIViewController {
|
||||
MP_AnalyticsManager.shared.getOpenStatus { [weak self] open in
|
||||
guard let self = self else {return}
|
||||
if open {
|
||||
//开关检测为通过,以下发ID刷新广告
|
||||
MP_ADSimpleManager.shared.loadMoreAds()
|
||||
MP_ADSimpleManager.shared.showOpenAdIfAvailable(.ICE) { [weak self] (ad, isOpen, platform) in
|
||||
guard let self = self else {return}
|
||||
addValue = 3
|
||||
//将广告事件传递闭包赋值
|
||||
adShowBlock = {
|
||||
self.adPresent(ad: ad, isOpen: isOpen, platform: platform)
|
||||
}
|
||||
}
|
||||
loadAds()
|
||||
//根据ip值确定进入那个页面
|
||||
MP_NetWorkManager.shared.requestIPInfo { statu in
|
||||
if statu == true {
|
||||
@ -258,16 +242,7 @@ class MP_LunchViewController: UIViewController {
|
||||
}
|
||||
}
|
||||
}else {
|
||||
//开关检测未通过,以默认ID刷新广告
|
||||
MP_ADSimpleManager.shared.loadMoreAds()
|
||||
MP_ADSimpleManager.shared.showOpenAdIfAvailable(.ICE) { [weak self] (ad, isOpen, platform) in
|
||||
guard let self = self else {return}
|
||||
addValue = 3
|
||||
//将广告事件传递闭包赋值
|
||||
adShowBlock = {
|
||||
self.adPresent(ad: ad, isOpen: isOpen, platform: platform)
|
||||
}
|
||||
}
|
||||
loadAds()
|
||||
print("ALog")
|
||||
//打开A面
|
||||
if self.maxTimes > self.currentTimes {
|
||||
@ -299,6 +274,29 @@ class MP_LunchViewController: UIViewController {
|
||||
}
|
||||
}
|
||||
}
|
||||
//加载屏显示广告
|
||||
private func loadAds(){
|
||||
if MP_ADSimpleManager.shared.openAdStatus {
|
||||
//开关检测未通过,以默认ID刷新广告
|
||||
MP_ADSimpleManager.shared.loadMoreAds()
|
||||
MP_ADSimpleManager.shared.showOpenAdIfAvailable(.ICE) { [weak self] (ad, isOpen, platform) in
|
||||
self?.addValue = 3
|
||||
guard let self = self else {return}
|
||||
//将广告事件传递闭包赋值
|
||||
adShowBlock = {
|
||||
self.adPresent(ad: ad, isOpen: isOpen, platform: platform)
|
||||
}
|
||||
}
|
||||
}else {
|
||||
//接受数据更新通知
|
||||
NotificationCenter.notificationKey.add(observer: self, selector: #selector(resourceAction(_ :)), notificationName: .positive_browses_reload)
|
||||
}
|
||||
}
|
||||
@objc func resourceAction(_ sender:Notification) {
|
||||
if MPPositive_BrowseLoadViewModel.shared.browseModuleLists.isEmpty == false {
|
||||
self.addValue = 3
|
||||
}
|
||||
}
|
||||
//广告弹出
|
||||
private func adPresent(ad: AnyObject, isOpen:Bool, platform:Bool) {
|
||||
DispatchQueue.main.async {
|
||||
|
||||
@ -47,7 +47,13 @@ class MP_ADSimpleManager: NSObject {
|
||||
}
|
||||
}
|
||||
///广告总开关
|
||||
var openAdStatus:Bool = true
|
||||
var openAdStatus:Bool{
|
||||
if let bool = UserDefaults.standard.object(forKey: "UserVIPLevels") as? Bool{
|
||||
return bool
|
||||
}else {
|
||||
return true
|
||||
}
|
||||
}
|
||||
///内部使用广告开光
|
||||
var internalAdStatus:Bool = true
|
||||
///设置广告总开关
|
||||
@ -55,7 +61,7 @@ class MP_ADSimpleManager: NSObject {
|
||||
DispatchQueue.main.async {
|
||||
[weak self] in
|
||||
guard let self = self else {return}
|
||||
openAdStatus = bool
|
||||
UserDefaults.standard.set(bool, forKey: "UserVIPLevels")
|
||||
}
|
||||
}
|
||||
///插页广告总开关
|
||||
@ -109,7 +115,9 @@ class MP_ADSimpleManager: NSObject {
|
||||
}
|
||||
///展示开屏广告
|
||||
func showOpenAdIfAvailable(_ type:OpenType, completion:((_ ad:AnyObject, _ isOpen:Bool, _ platform:Bool) -> Void)?) {
|
||||
guard openAdStatus, internalAdStatus else {return}
|
||||
guard openAdStatus, internalAdStatus else {
|
||||
return
|
||||
}
|
||||
if platform {
|
||||
if let block = completion {
|
||||
MP_AppLovinManager.shared.showOpenAdIfAvailable {[weak self] ad in
|
||||
@ -153,7 +161,10 @@ class MP_ADSimpleManager: NSObject {
|
||||
}
|
||||
///展示播放广告
|
||||
func showPlayInterstitialAdIfAvailable(_ completion:((AnyObject?, Bool) -> Void)?) {
|
||||
guard openAdStatus, internalAdStatus else {return}
|
||||
guard openAdStatus, internalAdStatus else {
|
||||
completion?(nil, false)
|
||||
return
|
||||
}
|
||||
if platform {
|
||||
if let block = completion {
|
||||
MP_AppLovinManager.shared.showPlayInterstitialAdIfAvailable { ad in
|
||||
|
||||
@ -7,6 +7,9 @@
|
||||
|
||||
import UIKit
|
||||
import SVProgressHUD
|
||||
let HUDBackColor:UIColor = .init(hex: "#808080", alpha: 0.7)
|
||||
let HUDTextColor:UIColor = .white
|
||||
|
||||
///二次封装hud
|
||||
class MP_HUD: NSObject {
|
||||
//HUD输出状态
|
||||
@ -28,8 +31,8 @@ class MP_HUD: NSObject {
|
||||
static func loading(){
|
||||
SVProgressHUD.setDefaultStyle(.light)
|
||||
SVProgressHUD.setDefaultMaskType(.clear)
|
||||
SVProgressHUD.setBackgroundColor(.init(hex: "#80F988", alpha: 0.15))
|
||||
SVProgressHUD.setForegroundColor(.init(hex: "#80F988"))
|
||||
SVProgressHUD.setBackgroundColor(HUDBackColor)
|
||||
SVProgressHUD.setForegroundColor(HUDTextColor)
|
||||
SVProgressHUD.setOffsetFromCenter(.init(horizontal: 0, vertical: 0))
|
||||
if MP_ADSimpleManager.shared.getInterstitialSwitch() {
|
||||
//当前正在展示插页
|
||||
@ -43,8 +46,8 @@ class MP_HUD: NSObject {
|
||||
static func downloadText(_ text:String, delay:TimeInterval, completion:(() -> Void)?) {
|
||||
SVProgressHUD.setDefaultStyle(.light)
|
||||
SVProgressHUD.setDefaultMaskType(.none)
|
||||
SVProgressHUD.setBackgroundColor(.init(hex: "#80F988", alpha: 0.15))
|
||||
SVProgressHUD.setForegroundColor(.init(hex: "#80F988"))
|
||||
SVProgressHUD.setBackgroundColor(HUDBackColor)
|
||||
SVProgressHUD.setForegroundColor(HUDTextColor)
|
||||
SVProgressHUD.setOffsetFromCenter(.init(horizontal: 0, vertical: 0))
|
||||
if MP_ADSimpleManager.shared.getInterstitialSwitch() {
|
||||
//当前正在展示插页
|
||||
@ -101,8 +104,8 @@ class MP_HUD: NSObject {
|
||||
static func showWithStatus(hudStatus status: status, text: String?, delay: TimeInterval ,completion:(() -> Void)?) {
|
||||
SVProgressHUD.setDefaultStyle(.light)
|
||||
SVProgressHUD.setDefaultMaskType(.clear)
|
||||
SVProgressHUD.setBackgroundColor(.init(hex: "#80F988", alpha: 0.15))
|
||||
SVProgressHUD.setForegroundColor(.init(hex: "#80F988"))
|
||||
SVProgressHUD.setBackgroundColor(HUDBackColor)
|
||||
SVProgressHUD.setForegroundColor(HUDTextColor)
|
||||
SVProgressHUD.setOffsetFromCenter(.init(horizontal: 0, vertical: 0))
|
||||
if MP_ADSimpleManager.shared.getInterstitialSwitch() {
|
||||
//当前正在展示插页
|
||||
@ -113,12 +116,12 @@ class MP_HUD: NSObject {
|
||||
}else {
|
||||
switch status {
|
||||
case .success:
|
||||
SVProgressHUD.setBackgroundColor(.init(hex: "#80F988", alpha: 0.15))
|
||||
SVProgressHUD.setBackgroundColor(HUDBackColor)
|
||||
SVProgressHUD.showSuccess(withStatus: text)
|
||||
SVProgressHUD.setMinimumSize(CGSize(width: 100 * width, height: 80 * width))
|
||||
SVProgressHUD.show(UIImage(), status: text)
|
||||
case .error:
|
||||
SVProgressHUD.setBackgroundColor(.init(hex: "#80F988", alpha: 0.15))
|
||||
SVProgressHUD.setBackgroundColor(HUDBackColor)
|
||||
SVProgressHUD.showError(withStatus: text)
|
||||
case .onlyText:
|
||||
SVProgressHUD.setMinimumSize(CGSize(width: 100 * width, height: 40 * width))
|
||||
|
||||
@ -2055,7 +2055,7 @@ extension MP_NetWorkManager {
|
||||
}else {
|
||||
//不存在资源(通常是IP被拉黑了)
|
||||
failure?(true)
|
||||
MP_HUD.error("Failed to obtain resource, please try again later", delay: 1.0, completion: nil)
|
||||
MP_HUD.error("Failed to obtain resource, please try again later".localizableString(), delay: 1.0, completion: nil)
|
||||
MP_AnalyticsManager.shared.player_resource_failureAction(locaton ?? "HK")
|
||||
}
|
||||
}
|
||||
|
||||
@ -511,10 +511,12 @@ class MP_PlayerManager:NSObject{
|
||||
guard let self = self else {return}
|
||||
//10秒后检索播放器是否在播放
|
||||
if playState != .Playing {
|
||||
if isLast == true {
|
||||
MP_HUD.text("Failed to obtain resource, please try again later".localizableString(), delay: 2.0, completion: nil)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//获取缓冲值
|
||||
private func cacheLoadTimes() {
|
||||
//获取当前播放Item的缓冲值组
|
||||
|
||||
@ -66,7 +66,8 @@ class MPPositive_MoreSongOperationsViewController: UIViewController, UIViewContr
|
||||
subtitleLabel.text = song.shortBylineText
|
||||
//判断该单曲是否收藏
|
||||
MPPositive_CollectionSongModel.fetch(predicate: .init(format: "videoId == %@", (song.videoId ?? ""))) { [weak self] results in
|
||||
self?.collectionBtn.isSelected = results.count != 0
|
||||
guard let self = self else {return}
|
||||
collectionBtn.isSelected = results.count != 0
|
||||
}
|
||||
tableView.reloadData()
|
||||
}
|
||||
@ -254,6 +255,11 @@ class MPPositive_MoreSongOperationsViewController: UIViewController, UIViewContr
|
||||
view.layer.masksToBounds = true
|
||||
view.layer.maskedCorners = [.layerMinXMinYCorner,.layerMaxXMinYCorner]
|
||||
view.layer.cornerRadius = 18*width
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
|
||||
if MP_NetWorkManager.shared.netWorkStatu != .reachable {
|
||||
MP_HUD.onlytext("Bad connection~", delay: 1.0, completion: nil)
|
||||
}
|
||||
}
|
||||
configure()
|
||||
}
|
||||
override func viewWillAppear(_ animated: Bool) {
|
||||
|
||||
@ -0,0 +1,96 @@
|
||||
//
|
||||
// MPPositive_AddSongsViewController.swift
|
||||
// relax.offline.mp3.music
|
||||
//
|
||||
// Created by Mr.Zhou on 2024/9/24.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
class MPPositive_AddSongsViewController: MPPositive_BaseViewController {
|
||||
//分页栏View
|
||||
lazy var segmentView:JXSegmentedView = {
|
||||
var jxSegmentView = JXSegmentedView()
|
||||
jxSegmentView.backgroundColor = .init(hex: "1A1A1A")
|
||||
return jxSegmentView
|
||||
}()
|
||||
//数据源
|
||||
private lazy var dataSource:JXSegmentedTitleDataSource = {
|
||||
var dataSource = JXSegmentedTitleDataSource()
|
||||
dataSource.titles = ["Love Songs".localizableString(), "Offline Songs".localizableString()]
|
||||
//标题未选中状态
|
||||
dataSource.titleNormalColor = .init(hex: "#666666")
|
||||
dataSource.titleNormalFont = .systemFont(ofSize: 16*width, weight: .regular)
|
||||
//标题选中状态
|
||||
dataSource.titleSelectedColor = .init(hex: "#80F988")
|
||||
dataSource.titleSelectedFont = .systemFont(ofSize: 16*width, weight: .bold)
|
||||
//是否颜色过度
|
||||
dataSource.isTitleColorGradientEnabled = true
|
||||
dataSource.isSelectedAnimable = true
|
||||
dataSource.isItemTransitionEnabled = true
|
||||
return dataSource
|
||||
}()
|
||||
//指示器
|
||||
private lazy var indicator:JXSegmentedIndicatorLineView = {
|
||||
let indicator = JXSegmentedIndicatorLineView()
|
||||
indicator.indicatorWidth = 16*width
|
||||
indicator.indicatorHeight = 3*width
|
||||
indicator.indicatorCornerRadius = 1.5*width
|
||||
indicator.indicatorColor = .init(hex: "#80F988")
|
||||
indicator.indicatorPosition = .bottom
|
||||
return indicator
|
||||
}()
|
||||
//分页内容承载框
|
||||
fileprivate lazy var listContainerView:JXSegmentedListContainerView = {
|
||||
let listContainerView = JXSegmentedListContainerView(dataSource: self)
|
||||
listContainerView.backgroundColor = .clear
|
||||
return listContainerView
|
||||
}()
|
||||
var list:MPPositive_CustomPlayListModel!
|
||||
init(playList:MPPositive_CustomPlayListModel) {
|
||||
super.init(nibName: nil, bundle: nil)
|
||||
self.list = playList
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
super.init(coder: coder)
|
||||
}
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
setTitle("Add Songs")
|
||||
setPopBtn()
|
||||
configure()
|
||||
}
|
||||
private func configure() {
|
||||
//添加分页
|
||||
segmentView.indicators = [indicator]
|
||||
segmentView.dataSource = dataSource
|
||||
view.addSubview(segmentView)
|
||||
segmentView.snp.makeConstraints { make in
|
||||
make.top.equalTo(navView.snp.bottom)
|
||||
make.left.right.equalToSuperview()
|
||||
make.height.equalTo(60*width)
|
||||
}
|
||||
view.addSubview(listContainerView)
|
||||
listContainerView.snp.makeConstraints { (make) in
|
||||
make.left.right.bottom.equalToSuperview().priority(999)
|
||||
make.top.equalTo(segmentView.snp.bottom).priority(999)
|
||||
}
|
||||
segmentView.contentScrollView = listContainerView.scrollView
|
||||
segmentView.listContainer = listContainerView
|
||||
}
|
||||
}
|
||||
//MARK: - JXSegmentedTitleDataSource
|
||||
extension MPPositive_AddSongsViewController: JXSegmentedListContainerViewDataSource, JXSegmentedViewDelegate {
|
||||
func numberOfLists(in listContainerView: JXSegmentedListContainerView) -> Int {
|
||||
return dataSource.titles.count
|
||||
}
|
||||
|
||||
func listContainerView(_ listContainerView: JXSegmentedListContainerView, initListAt index: Int) -> any JXSegmentedListContainerViewListDelegate {
|
||||
let showView:MPPositive_AddSongsShowView = .init(frame: listContainerView.frame, playList: list)
|
||||
showView.selectedIndex = index
|
||||
return showView
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -85,6 +85,17 @@ class MPPositive_CustomPlayListViewController: MPPositive_BaseViewController, UI
|
||||
btn.addTarget(self, action: #selector(shuffleClick(_ :)), for: .touchUpInside)
|
||||
return btn
|
||||
}()
|
||||
///添加音乐
|
||||
private lazy var addBtn:UIButton = {
|
||||
let btn = UIButton()
|
||||
btn.setImage(UIImage(named: "New_AddSong'logo"), for: .normal)
|
||||
//添加点击
|
||||
btn.setTitle(" Add", for: .normal)
|
||||
btn.setTitleColor(.white, for: .normal)
|
||||
btn.titleLabel?.font = .systemFont(ofSize: 14*width, weight: .regular)
|
||||
btn.addTarget(self, action: #selector(addSongActionClick(_ :)), for: .touchUpInside)
|
||||
return btn
|
||||
}()
|
||||
///搜索按钮
|
||||
private lazy var searchBtn:UIButton = {
|
||||
let btn = UIButton()
|
||||
@ -185,6 +196,9 @@ class MPPositive_CustomPlayListViewController: MPPositive_BaseViewController, UI
|
||||
}
|
||||
override func viewWillAppear(_ animated: Bool) {
|
||||
super.viewWillAppear(animated)
|
||||
if list != nil {
|
||||
reload(list)
|
||||
}
|
||||
}
|
||||
override func viewWillDisappear(_ animated: Bool) {
|
||||
super.viewWillDisappear(animated)
|
||||
@ -279,7 +293,13 @@ class MPPositive_CustomPlayListViewController: MPPositive_BaseViewController, UI
|
||||
//随机播放按钮
|
||||
sectionShowView.addSubview(shuffleBtn)
|
||||
shuffleBtn.snp.makeConstraints { make in
|
||||
make.left.equalTo(playAllBtn.snp.right).offset(18*width)
|
||||
make.left.equalTo(playAllBtn.snp.right).offset(14*width)
|
||||
make.centerY.equalTo(playAllBtn)
|
||||
}
|
||||
//添加歌曲
|
||||
sectionShowView.addSubview(addBtn)
|
||||
addBtn.snp.makeConstraints { make in
|
||||
make.left.equalTo(shuffleBtn.snp.right).offset(14*width)
|
||||
make.centerY.equalTo(playAllBtn)
|
||||
}
|
||||
//搜索
|
||||
@ -378,6 +398,7 @@ class MPPositive_CustomPlayListViewController: MPPositive_BaseViewController, UI
|
||||
}
|
||||
//播放全部
|
||||
@objc private func playAllClick(_ sender:UIButton) {
|
||||
view.endEditing(true)
|
||||
guard list.videosArray.count != 0 else {return}
|
||||
MPPositive_Debouncer.shared.call {
|
||||
[weak self] in
|
||||
@ -416,6 +437,7 @@ class MPPositive_CustomPlayListViewController: MPPositive_BaseViewController, UI
|
||||
}
|
||||
//随机播放
|
||||
@objc private func shuffleClick(_ sender:UIButton) {
|
||||
view.endEditing(true)
|
||||
guard list.videosArray.count != 0 else {return}
|
||||
MPPositive_Debouncer.shared.call {
|
||||
[weak self] in
|
||||
@ -454,8 +476,17 @@ class MPPositive_CustomPlayListViewController: MPPositive_BaseViewController, UI
|
||||
MP_AnalyticsManager.shared.player_b_listAction()
|
||||
}
|
||||
}
|
||||
//添加点击事件
|
||||
@objc private func addSongActionClick(_ sender:UIButton) {
|
||||
view.endEditing(true)
|
||||
cancelSearchAction()
|
||||
//加载Add控制器
|
||||
let addVC = MPPositive_AddSongsViewController(playList: list)
|
||||
navigationController?.pushViewController(addVC, animated: true)
|
||||
}
|
||||
//搜索
|
||||
@objc private func searchActionShowClick(_ sender:UIButton) {
|
||||
view.endEditing(true)
|
||||
//点击搜索时,展示搜索框
|
||||
UIView.animate(withDuration: 0.2) {
|
||||
[weak self] in
|
||||
|
||||
@ -44,13 +44,13 @@ class MPPositive_PlayerViewController: MPPositive_BaseViewController, UIViewCont
|
||||
private lazy var songBtn:UIButton = createStatueBtn("SONG", color: .init(hex: "#FFFFFF", alpha: 0.85), tag: 0)
|
||||
//生成LYRICS按钮
|
||||
private lazy var lyricsBtn:UIButton = createStatueBtn("LYRICS", color: .init(hex: "#FFFFFF", alpha: 0.45), tag: 1)
|
||||
//右侧关联按钮
|
||||
private lazy var relatedBtn:UIButton = {
|
||||
let btn = UIButton()
|
||||
btn.setBackgroundImage(UIImage(named: "Player_Related'logo"), for: .normal)
|
||||
btn.addTarget(self, action: #selector(relatedContentClick(_ :)), for: .touchUpInside)
|
||||
return btn
|
||||
}()
|
||||
// //右侧关联按钮
|
||||
// private lazy var relatedBtn:UIButton = {
|
||||
// let btn = UIButton()
|
||||
// btn.setBackgroundImage(UIImage(named: "Player_Related'logo"), for: .normal)
|
||||
// btn.addTarget(self, action: #selector(relatedContentClick(_ :)), for: .touchUpInside)
|
||||
// return btn
|
||||
// }()
|
||||
|
||||
//MARK: - 背景视图
|
||||
//背景封面图
|
||||
@ -154,6 +154,28 @@ class MPPositive_PlayerViewController: MPPositive_BaseViewController, UIViewCont
|
||||
activityIndicator.color = .black
|
||||
return activityIndicator
|
||||
}()
|
||||
//底部相关内容按钮
|
||||
private lazy var relatedBtn:UIButton = {
|
||||
let btn:UIButton = .init()
|
||||
btn.setBackgroundImage(UIImage(named: "Player_SmallBack'logo"), for: .normal)
|
||||
btn.setImage(UIImage(named: "Player_Related'logo 1"), for: .normal)
|
||||
btn.setTitle(" Related", for: .normal)
|
||||
btn.setTitleColor(.white, for: .normal)
|
||||
btn.titleLabel?.font = .systemFont(ofSize: 14*width)
|
||||
btn.addTarget(self, action: #selector(relatedContentClick(_ :)), for: .touchUpInside)
|
||||
return btn
|
||||
}()
|
||||
//底部添加歌单按钮
|
||||
private lazy var addPlayListBtn:UIButton = {
|
||||
let btn:UIButton = .init()
|
||||
btn.setBackgroundImage(UIImage(named: "Player_SmallBack'logo"), for: .normal)
|
||||
btn.setImage(UIImage(named: "Player_AddPlayList'logo"), for: .normal)
|
||||
btn.setTitle(" Add Playlist", for: .normal)
|
||||
btn.setTitleColor(.white, for: .normal)
|
||||
btn.titleLabel?.font = .systemFont(ofSize: 14*width)
|
||||
btn.addTarget(self, action: #selector(addPlayListClick(_ :)), for: .touchUpInside)
|
||||
return btn
|
||||
}()
|
||||
//下载引导层
|
||||
private lazy var leadMaskView:UIView = {
|
||||
let maskView = UIView(frame: .init(x: 0, y: 0, width: screen_Width, height: screen_Height))
|
||||
@ -309,12 +331,12 @@ class MPPositive_PlayerViewController: MPPositive_BaseViewController, UIViewCont
|
||||
make.left.equalToSuperview().offset(16*width)
|
||||
make.centerY.equalToSuperview()
|
||||
}
|
||||
navView.addSubview(relatedBtn)
|
||||
relatedBtn.snp.makeConstraints { make in
|
||||
make.width.height.equalTo(24*width)
|
||||
make.right.equalToSuperview().offset(-16*width)
|
||||
make.centerY.equalToSuperview()
|
||||
}
|
||||
// navView.addSubview(relatedBtn)
|
||||
// relatedBtn.snp.makeConstraints { make in
|
||||
// make.width.height.equalTo(24*width)
|
||||
// make.right.equalToSuperview().offset(-16*width)
|
||||
// make.centerY.equalToSuperview()
|
||||
// }
|
||||
navView.addSubview(switchActionView)
|
||||
switchActionView.snp.makeConstraints { make in
|
||||
make.height.equalToSuperview()
|
||||
@ -425,7 +447,7 @@ class MPPositive_PlayerViewController: MPPositive_BaseViewController, UIViewCont
|
||||
playBtn.snp.makeConstraints { make in
|
||||
make.width.height.equalTo(66*width)
|
||||
make.centerX.equalToSuperview()
|
||||
make.centerY.equalToSuperview().multipliedBy(1.1)
|
||||
make.centerY.equalToSuperview().multipliedBy(1.1).offset(-bottomPadding)
|
||||
}
|
||||
bottomView.addSubview(activityIndicator)
|
||||
activityIndicator.snp.makeConstraints { make in
|
||||
@ -465,6 +487,18 @@ class MPPositive_PlayerViewController: MPPositive_BaseViewController, UIViewCont
|
||||
make.centerY.equalTo(playBtn.snp.centerY)
|
||||
make.left.equalToSuperview().offset(98*width)
|
||||
}
|
||||
bottomView.addSubview(relatedBtn)
|
||||
relatedBtn.snp.makeConstraints { make in
|
||||
make.top.equalTo(playBtn.snp.bottom).offset(15*width)
|
||||
make.size.equalTo(CGSize(width: 151*width, height: 39*width))
|
||||
make.centerX.equalToSuperview().multipliedBy(0.5)
|
||||
}
|
||||
bottomView.addSubview(addPlayListBtn)
|
||||
addPlayListBtn.snp.makeConstraints { make in
|
||||
make.top.equalTo(relatedBtn)
|
||||
make.size.equalTo(relatedBtn.snp.size)
|
||||
make.centerX.equalToSuperview().multipliedBy(1.5)
|
||||
}
|
||||
return bottomView
|
||||
}
|
||||
//设置阴影层
|
||||
@ -661,6 +695,9 @@ class MPPositive_PlayerViewController: MPPositive_BaseViewController, UIViewCont
|
||||
coverView.alpha = 0.1
|
||||
songBtn.setTitleColor(.init(hex: "#FFFFFF", alpha: 0.45), for: .normal)
|
||||
lyricsBtn.setTitleColor(.init(hex: "#FFFFFF", alpha: 0.85), for: .normal)
|
||||
if let currentVideo = MP_PlayerManager.shared.loadPlayer?.currentVideo {
|
||||
lyricsView.lyricsLabel.text = currentVideo.lyrics ?? "No Lyrics"
|
||||
}
|
||||
} completion: { [weak self] (_) in
|
||||
guard let self = self else {return}
|
||||
//平移结束后,隐藏coverView
|
||||
@ -683,7 +720,22 @@ class MPPositive_PlayerViewController: MPPositive_BaseViewController, UIViewCont
|
||||
}
|
||||
dismiss(animated: true)
|
||||
}
|
||||
|
||||
//添加进歌单
|
||||
@objc private func addPlayListClick(_ sender:UIButton) {
|
||||
guard let currentVideo = MP_PlayerManager.shared.loadPlayer?.currentVideo else {
|
||||
return
|
||||
}
|
||||
//选择歌单
|
||||
MPPositive_ModalType = .MoreOperations
|
||||
let chooseVC = MPPositive_ChoosePlayListViewController(currentVideo.song)
|
||||
chooseVC.disMissBlock = {
|
||||
[weak self] in
|
||||
print("Add Successfull")
|
||||
}
|
||||
chooseVC.transitioningDelegate = self
|
||||
chooseVC.modalPresentationStyle = .custom
|
||||
present(chooseVC, animated: true)
|
||||
}
|
||||
//播放/暂停/继续
|
||||
@objc private func playClick(_ sender:UIButton) {
|
||||
|
||||
|
||||
@ -54,7 +54,7 @@ class MPPositive_CustomTabBarItem: UIView {
|
||||
//添加圆圈
|
||||
addSubview(circleImageView)
|
||||
circleImageView.snp.makeConstraints { make in
|
||||
make.width.height.equalToSuperview()
|
||||
make.width.height.equalTo(36*width)
|
||||
make.center.equalToSuperview()
|
||||
}
|
||||
circleImageView.isHidden = true
|
||||
|
||||
@ -57,7 +57,8 @@ class MPPositive_CustomTabBarView: UIView {
|
||||
addSubview(item)
|
||||
item.snp.makeConstraints { make in
|
||||
make.centerY.equalToSuperview()
|
||||
make.width.height.equalTo(36*width)
|
||||
make.width.equalToSuperview().multipliedBy(0.28)
|
||||
make.height.equalToSuperview()
|
||||
make.centerX.equalToSuperview().multipliedBy(0.45 + 0.55*Double(item.tag))
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,102 @@
|
||||
//
|
||||
// MPPositive_AddSongTableViewCell.swift
|
||||
// relax.offline.mp3.music
|
||||
//
|
||||
// Created by Mr.Zhou on 2024/9/24.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import Kingfisher
|
||||
class MPPositive_AddSongTableViewCell: UITableViewCell {
|
||||
//特殊图片(展示预览图片)
|
||||
private lazy var iconImageView:UIImageView = {
|
||||
let imageView:UIImageView = .init()
|
||||
imageView.contentMode = .scaleAspectFill
|
||||
imageView.layer.masksToBounds = true
|
||||
imageView.layer.cornerRadius = 8*width
|
||||
return imageView
|
||||
}()
|
||||
private lazy var titleLabel:UILabel = createLabel(font: .systemFont(ofSize: 16*width, weight: .regular), textColor: .white, textAlignment: .left)
|
||||
private lazy var subtitleLabel:UILabel = createLabel(font: .systemFont(ofSize: 12*width, weight: .regular), textColor: .init(hex: "#999999"), textAlignment: .left)
|
||||
//是否添加按钮
|
||||
lazy var statuImageView:UIImageView = {
|
||||
let imageView:UIImageView = .init()
|
||||
imageView.contentMode = .scaleAspectFill
|
||||
return imageView
|
||||
}()
|
||||
var list:MPPositive_CustomPlayListModel?
|
||||
var love:MPPositive_CollectionSongViewModel!{
|
||||
didSet{
|
||||
love.setImage(iconImageView)
|
||||
titleLabel.text = love.title
|
||||
subtitleLabel.text = love.subtitle
|
||||
//检索list中是否存在
|
||||
if let array = list?.videosArray.filter({$0.videoId == love.collectionSong.videoId}), array.isEmpty == true {
|
||||
statuImageView.image = UIImage(named: "UnAdd_PlayLists'logo")
|
||||
}else {
|
||||
statuImageView.image = UIImage(named: "Added_PlayList'logo")
|
||||
}
|
||||
}
|
||||
}
|
||||
var offline:MPPositive_DownloadViewModel!{
|
||||
didSet{
|
||||
offline.setImage(iconImageView)
|
||||
titleLabel.text = offline.title
|
||||
subtitleLabel.text = offline.subtitle
|
||||
//检索list中是否存在
|
||||
if let array = list?.videosArray.filter({$0.videoId == offline.loadItem.videoId}), array.isEmpty == true {
|
||||
statuImageView.image = UIImage(named: "UnAdd_PlayLists'logo")
|
||||
}else {
|
||||
statuImageView.image = UIImage(named: "Added_PlayList'logo")
|
||||
}
|
||||
}
|
||||
}
|
||||
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
|
||||
super.init(style: style, reuseIdentifier: reuseIdentifier)
|
||||
selectionStyle = .none
|
||||
backgroundColor = .clear
|
||||
configure()
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
super.init(coder: coder)
|
||||
}
|
||||
override func awakeFromNib() {
|
||||
super.awakeFromNib()
|
||||
// Initialization code
|
||||
}
|
||||
|
||||
override func setSelected(_ selected: Bool, animated: Bool) {
|
||||
super.setSelected(selected, animated: animated)
|
||||
|
||||
// Configure the view for the selected state
|
||||
}
|
||||
private func configure() {
|
||||
contentView.addSubview(iconImageView)
|
||||
iconImageView.snp.makeConstraints { make in
|
||||
make.width.height.equalTo(60*width)
|
||||
make.top.equalToSuperview().offset(12*width).priority(999)
|
||||
make.bottom.equalToSuperview().offset(-12*width)
|
||||
make.left.equalToSuperview().offset(16*width)
|
||||
}
|
||||
contentView.addSubview(titleLabel)
|
||||
titleLabel.snp.makeConstraints { make in
|
||||
make.top.equalTo(iconImageView.snp.top).offset(8*width)
|
||||
make.left.equalTo(iconImageView.snp.right).offset(14*width)
|
||||
make.right.equalToSuperview().offset(-16*width)
|
||||
}
|
||||
contentView.addSubview(subtitleLabel)
|
||||
subtitleLabel.snp.makeConstraints { make in
|
||||
make.bottom.equalTo(iconImageView.snp.bottom).offset(-8*width)
|
||||
make.left.equalTo(titleLabel.snp.left)
|
||||
make.right.equalTo(titleLabel.snp.right)
|
||||
}
|
||||
contentView.addSubview(statuImageView)
|
||||
statuImageView.snp.makeConstraints { make in
|
||||
make.size.equalTo(CGSize(width: 24*width, height: 24*width))
|
||||
make.centerY.equalToSuperview()
|
||||
make.right.equalTo(-18*width)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,143 @@
|
||||
//
|
||||
// MPPositive_AddSongsShowView.swift
|
||||
// relax.offline.mp3.music
|
||||
//
|
||||
// Created by Mr.Zhou on 2024/9/24.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
///选择歌曲
|
||||
class MPPositive_AddSongsShowView: UIView, JXSegmentedListContainerViewListDelegate {
|
||||
private lazy var tableView:UITableView = {
|
||||
let tableView = UITableView()
|
||||
if #available(iOS 15.0, *) {
|
||||
tableView.sectionHeaderTopPadding = 0
|
||||
}
|
||||
tableView.backgroundColor = .clear
|
||||
tableView.separatorStyle = .none
|
||||
tableView.estimatedRowHeight = 200
|
||||
tableView.rowHeight = UITableView.automaticDimension
|
||||
tableView.dataSource = self
|
||||
tableView.delegate = self
|
||||
tableView.contentInset = .init(top: 0, left: 0, bottom: 70*width, right: 0)
|
||||
tableView.register(MPPositive_AddSongTableViewCell.self, forCellReuseIdentifier: MPPositive_AddSongTableViewCellID)
|
||||
return tableView
|
||||
}()
|
||||
private let MPPositive_AddSongTableViewCellID = "MPPositive_AddSongTableViewCell"
|
||||
//当前展示的页面
|
||||
var selectedIndex:Int = 0
|
||||
///当前歌单数据
|
||||
var list:MPPositive_CustomPlayListModel?
|
||||
//收藏歌曲组
|
||||
private var loves:[MPPositive_CollectionSongViewModel] = []
|
||||
//离线歌曲组
|
||||
private var offlines:[MPPositive_DownloadViewModel] = []
|
||||
|
||||
init(frame: CGRect, playList:MPPositive_CustomPlayListModel) {
|
||||
super.init(frame: frame)
|
||||
self.list = playList
|
||||
backgroundColor = .init(hex: "1A1A1A")
|
||||
configure()
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
super.init(coder: coder)
|
||||
}
|
||||
|
||||
//MARK: - 分页代理
|
||||
func listView() -> UIView {
|
||||
return self
|
||||
}
|
||||
func listWillAppear() {
|
||||
reload()
|
||||
}
|
||||
//加载数据
|
||||
private func reload() {
|
||||
if selectedIndex == 0 {
|
||||
//更新搜藏歌曲
|
||||
MPPositive_LoadCoreModel.shared.reloadCollectionSongViewModel {
|
||||
[weak self] in
|
||||
guard let self = self else {return}
|
||||
loves = MPPositive_LoadCoreModel.shared.songViewModels
|
||||
tableView.showMessage(loves.count)
|
||||
tableView.reloadData()
|
||||
}
|
||||
}else {
|
||||
//更新离线歌曲
|
||||
MPPositive_LoadCoreModel.shared.reloadLoadSongViewModel {
|
||||
[weak self] in
|
||||
guard let self = self else {return}
|
||||
offlines = MPPositive_LoadCoreModel.shared.loadViewModels
|
||||
tableView.showMessage(offlines.count)
|
||||
tableView.reloadData()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//配置
|
||||
private func configure() {
|
||||
addSubview(tableView)
|
||||
tableView.snp.makeConstraints { make in
|
||||
make.left.top.right.bottom.equalToSuperview()
|
||||
}
|
||||
}
|
||||
}
|
||||
//MARK: - tableView
|
||||
extension MPPositive_AddSongsShowView:UITableViewDataSource, UITableViewDelegate {
|
||||
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
||||
return selectedIndex == 0 ? loves.count:offlines.count
|
||||
}
|
||||
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
||||
let cell = tableView.dequeueReusableCell(withIdentifier: MPPositive_AddSongTableViewCellID, for: indexPath) as! MPPositive_AddSongTableViewCell
|
||||
cell.list = list
|
||||
if selectedIndex == 0 {
|
||||
cell.love = loves[indexPath.row]
|
||||
}else {
|
||||
cell.offline = offlines[indexPath.row]
|
||||
}
|
||||
return cell
|
||||
}
|
||||
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
||||
if selectedIndex == 0 {
|
||||
let item = loves[indexPath.row]
|
||||
guard let array = list?.videosArray.filter({$0.videoId == item.collectionSong.videoId}), array.isEmpty == true else {
|
||||
return
|
||||
}
|
||||
//添加数据
|
||||
let video = try? MPPositive_CustomVideoModel.create()
|
||||
video?.coverImageURL = item.coverURL
|
||||
video?.title = item.title
|
||||
video?.subtitle = item.collectionSong.subtitle
|
||||
video?.videoId = item.collectionSong.videoId
|
||||
video?.lyricsID = item.collectionSong.lyricsID
|
||||
video?.relatedID = item.collectionSong.relatedID
|
||||
video?.addTime = Date().timeZone()
|
||||
video?.playList = list
|
||||
MPPositive_CustomVideoModel.save()
|
||||
MP_HUD.onlytext("Successfully added to the playlist".localizableString(), delay: 1.0) {
|
||||
[weak self] in
|
||||
self?.tableView.reloadData()
|
||||
}
|
||||
}else {
|
||||
let item = offlines[indexPath.row]
|
||||
guard let array = list?.videosArray.filter({$0.videoId == item.loadItem.videoId}), array.isEmpty == true else {
|
||||
return
|
||||
}
|
||||
//添加数据
|
||||
let video = try? MPPositive_CustomVideoModel.create()
|
||||
video?.coverImageURL = item.reviewURL
|
||||
video?.title = item.title
|
||||
video?.subtitle = item.loadItem.shortBylineText
|
||||
video?.videoId = item.loadItem.videoId
|
||||
video?.lyricsID = item.loadItem.lyricsID
|
||||
video?.relatedID = item.loadItem.relatedID
|
||||
video?.addTime = Date().timeZone()
|
||||
video?.playList = list
|
||||
MPPositive_CustomVideoModel.save()
|
||||
MP_HUD.onlytext("Successfully added to the playlist".localizableString(), delay: 1.0) {
|
||||
[weak self] in
|
||||
self?.tableView.reloadData()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -224,10 +224,10 @@ class MPPositive_ArtistShowSongTableViewCell: UITableViewCell, PKDownloadButtonD
|
||||
}
|
||||
//点击更多
|
||||
@objc private func moreActionClick(_ sender:UIButton) {
|
||||
guard MP_NetWorkManager.shared.netWorkStatu == .reachable else {
|
||||
MP_HUD.text("Bad connection~".localizableString(), delay: 2.0, completion: nil)
|
||||
return
|
||||
}
|
||||
// guard MP_NetWorkManager.shared.netWorkStatu == .reachable else {
|
||||
// MP_HUD.text("Bad connection~".localizableString(), delay: 2.0, completion: nil)
|
||||
// return
|
||||
// }
|
||||
guard moreBlock != nil else {
|
||||
return
|
||||
}
|
||||
|
||||
@ -232,10 +232,10 @@ class MPPositive_HomeSingleCollectionViewCell: UICollectionViewCell, PKDownloadB
|
||||
switch state {
|
||||
case .startDownload://开始状态,点击后进入下载状态
|
||||
//检索当前网络状态
|
||||
guard MP_NetWorkManager.shared.netWorkStatu == .reachable else {
|
||||
MP_HUD.text("Bad connection~".localizableString(), delay: 2.0, completion: nil)
|
||||
return
|
||||
}
|
||||
// guard MP_NetWorkManager.shared.netWorkStatu == .reachable else {
|
||||
// MP_HUD.text("Bad connection~".localizableString(), delay: 2.0, completion: nil)
|
||||
// return
|
||||
// }
|
||||
//检索当前歌曲是否下载过
|
||||
guard let videoId = itemViewModel.browseItem.videoId else {
|
||||
return
|
||||
|
||||
@ -249,10 +249,10 @@ class MPPositive_MusicItemShowTableViewCell: UITableViewCell, PKDownloadButtonDe
|
||||
}
|
||||
//点击更多
|
||||
@objc private func moreActionClick(_ sender:UIButton) {
|
||||
guard MP_NetWorkManager.shared.netWorkStatu == .reachable else {
|
||||
MP_HUD.text("Bad connection~".localizableString(), delay: 2.0, completion: nil)
|
||||
return
|
||||
}
|
||||
// guard MP_NetWorkManager.shared.netWorkStatu == .reachable else {
|
||||
// MP_HUD.text("Bad connection~".localizableString(), delay: 2.0, completion: nil)
|
||||
// return
|
||||
// }
|
||||
guard moreBlock != nil else {
|
||||
return
|
||||
}
|
||||
|
||||
@ -298,37 +298,39 @@ class MPPositive_PlayerCoverView: UIView, PKDownloadButtonDelegate {
|
||||
}
|
||||
//切换当前列表收藏状态
|
||||
@objc private func collectionSwitchClick(_ sender:UIButton) {
|
||||
|
||||
guard MP_NetWorkManager.shared.netWorkStatu == .reachable else {
|
||||
MP_HUD.text("Bad connection~".localizableString(), delay: 2.0, completion: nil)
|
||||
return
|
||||
}
|
||||
//根据当前按钮的状况确定是否收藏
|
||||
if self.collectionSongBtn.isSelected == true{
|
||||
//取消收藏
|
||||
self.collectionSongBtn.isSelected = false
|
||||
if MP_PlayerManager.shared.loadPlayer?.currentVideo != nil{
|
||||
MPPositive_CollectionSongModel.fetch(predicate: .init(format: "videoId == %@", (MP_PlayerManager.shared.loadPlayer?.currentVideo?.song.videoId ?? ""))) { [weak self] results in
|
||||
if let currentVideo = MP_PlayerManager.shared.loadPlayer?.currentVideo{
|
||||
//移除收藏实例
|
||||
MPPositive_CollectionSongModel.fetch(predicate: .init(format: "videoId == %@", (currentVideo.song.videoId ?? ""))) { [weak self] results in
|
||||
results.forEach { i in
|
||||
if i.videoId == MP_PlayerManager.shared.loadPlayer?.currentVideo?.song.videoId{
|
||||
if i.videoId == currentVideo.song.videoId{
|
||||
MPPositive_CollectionSongModel.delete(i)
|
||||
}
|
||||
}
|
||||
//更新当前播放音乐状态
|
||||
MP_PlayerManager.shared.loadPlayer?.currentVideo?.reloadCollectionAndDownLoad()
|
||||
MPPositive_LoadCoreModel.shared.reloadCollectionSongViewModel(nil)
|
||||
}
|
||||
MP_AnalyticsManager.shared.player_b_unlove_clickAction(MP_PlayerManager.shared.loadPlayer?.currentVideo?.song.videoId ?? "", videoname: MP_PlayerManager.shared.loadPlayer?.currentVideo?.song.title ?? "", artistname: MP_PlayerManager.shared.loadPlayer?.currentVideo?.song.shortBylineText ?? "")
|
||||
}
|
||||
}else{
|
||||
//添加收藏
|
||||
self.collectionSongBtn.isSelected = true
|
||||
if MP_PlayerManager.shared.loadPlayer?.currentVideo != nil{
|
||||
if let currentVideo = MP_PlayerManager.shared.loadPlayer?.currentVideo{
|
||||
//创建收藏实例
|
||||
let item = try? 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
|
||||
item?.lyricsID = MP_PlayerManager.shared.loadPlayer?.currentVideo.song.lyricsID
|
||||
item?.relatedID = MP_PlayerManager.shared.loadPlayer?.currentVideo.song.relatedID
|
||||
item?.title = currentVideo.title
|
||||
item?.videoId = currentVideo.song.videoId
|
||||
item?.subtitle = currentVideo.subtitle
|
||||
item?.coverImage = currentVideo.coverUrl
|
||||
item?.lyricsID = currentVideo.song.lyricsID
|
||||
item?.relatedID = currentVideo.song.relatedID
|
||||
item?.addTime = Date()
|
||||
MPPositive_CollectionSongModel.save()
|
||||
//更新当前播放音乐状态
|
||||
MP_PlayerManager.shared.loadPlayer?.currentVideo.reloadCollectionAndDownLoad()
|
||||
MPPositive_LoadCoreModel.shared.reloadCollectionSongViewModel(nil)
|
||||
MP_AnalyticsManager.shared.player_b_love_clickAction(MP_PlayerManager.shared.loadPlayer?.currentVideo?.song.videoId ?? "", videoname: MP_PlayerManager.shared.loadPlayer?.currentVideo?.song.title ?? "", artistname: MP_PlayerManager.shared.loadPlayer?.currentVideo?.song.shortBylineText ?? "")
|
||||
|
||||
@ -277,10 +277,10 @@ class MPPositive_SearchResultShowTableViewCell: UITableViewCell, PKDownloadButto
|
||||
|
||||
//点击更多
|
||||
@objc private func moreActionClick(_ sender:UIButton) {
|
||||
guard MP_NetWorkManager.shared.netWorkStatu == .reachable else {
|
||||
MP_HUD.text("Bad connection~".localizableString(), delay: 2.0, completion: nil)
|
||||
return
|
||||
}
|
||||
// guard MP_NetWorkManager.shared.netWorkStatu == .reachable else {
|
||||
// MP_HUD.text("Bad connection~".localizableString(), delay: 2.0, completion: nil)
|
||||
// return
|
||||
// }
|
||||
if moreBlock != nil {
|
||||
moreBlock!()
|
||||
}
|
||||
|
||||