b面1.0.4上架版本(bug修复,优化功能)
This commit is contained in:
parent
a9c62a68f6
commit
716180557b
@ -45,7 +45,6 @@
|
|||||||
CBAFCB082C0A10500054500E /* MP_AnalyticsManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = CBAFCA1F2C0A10500054500E /* MP_AnalyticsManager.swift */; };
|
CBAFCB082C0A10500054500E /* MP_AnalyticsManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = CBAFCA1F2C0A10500054500E /* MP_AnalyticsManager.swift */; };
|
||||||
CBAFCB092C0A10500054500E /* MP_AVURLAsset.swift in Sources */ = {isa = PBXBuildFile; fileRef = CBAFCA202C0A10500054500E /* MP_AVURLAsset.swift */; };
|
CBAFCB092C0A10500054500E /* MP_AVURLAsset.swift in Sources */ = {isa = PBXBuildFile; fileRef = CBAFCA202C0A10500054500E /* MP_AVURLAsset.swift */; };
|
||||||
CBAFCB0A2C0A10500054500E /* MP_CacheManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = CBAFCA212C0A10500054500E /* MP_CacheManager.swift */; };
|
CBAFCB0A2C0A10500054500E /* MP_CacheManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = CBAFCA212C0A10500054500E /* MP_CacheManager.swift */; };
|
||||||
CBAFCB0B2C0A10500054500E /* MP_CircularProgressView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CBAFCA222C0A10500054500E /* MP_CircularProgressView.swift */; };
|
|
||||||
CBAFCB0C2C0A10500054500E /* MP_CoreDataHandlerManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = CBAFCA232C0A10500054500E /* MP_CoreDataHandlerManager.swift */; };
|
CBAFCB0C2C0A10500054500E /* MP_CoreDataHandlerManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = CBAFCA232C0A10500054500E /* MP_CoreDataHandlerManager.swift */; };
|
||||||
CBAFCB0D2C0A10500054500E /* MP_DownloadManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = CBAFCA242C0A10500054500E /* MP_DownloadManager.swift */; };
|
CBAFCB0D2C0A10500054500E /* MP_DownloadManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = CBAFCA242C0A10500054500E /* MP_DownloadManager.swift */; };
|
||||||
CBAFCB0E2C0A10500054500E /* MP_HUD.swift in Sources */ = {isa = PBXBuildFile; fileRef = CBAFCA252C0A10500054500E /* MP_HUD.swift */; };
|
CBAFCB0E2C0A10500054500E /* MP_HUD.swift in Sources */ = {isa = PBXBuildFile; fileRef = CBAFCA252C0A10500054500E /* MP_HUD.swift */; };
|
||||||
@ -254,7 +253,6 @@
|
|||||||
CBAFCA1F2C0A10500054500E /* MP_AnalyticsManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MP_AnalyticsManager.swift; sourceTree = "<group>"; };
|
CBAFCA1F2C0A10500054500E /* MP_AnalyticsManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MP_AnalyticsManager.swift; sourceTree = "<group>"; };
|
||||||
CBAFCA202C0A10500054500E /* MP_AVURLAsset.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MP_AVURLAsset.swift; sourceTree = "<group>"; };
|
CBAFCA202C0A10500054500E /* MP_AVURLAsset.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MP_AVURLAsset.swift; sourceTree = "<group>"; };
|
||||||
CBAFCA212C0A10500054500E /* MP_CacheManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MP_CacheManager.swift; sourceTree = "<group>"; };
|
CBAFCA212C0A10500054500E /* MP_CacheManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MP_CacheManager.swift; sourceTree = "<group>"; };
|
||||||
CBAFCA222C0A10500054500E /* MP_CircularProgressView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MP_CircularProgressView.swift; sourceTree = "<group>"; };
|
|
||||||
CBAFCA232C0A10500054500E /* MP_CoreDataHandlerManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MP_CoreDataHandlerManager.swift; sourceTree = "<group>"; };
|
CBAFCA232C0A10500054500E /* MP_CoreDataHandlerManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MP_CoreDataHandlerManager.swift; sourceTree = "<group>"; };
|
||||||
CBAFCA242C0A10500054500E /* MP_DownloadManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MP_DownloadManager.swift; sourceTree = "<group>"; };
|
CBAFCA242C0A10500054500E /* MP_DownloadManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MP_DownloadManager.swift; sourceTree = "<group>"; };
|
||||||
CBAFCA252C0A10500054500E /* MP_HUD.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MP_HUD.swift; sourceTree = "<group>"; };
|
CBAFCA252C0A10500054500E /* MP_HUD.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MP_HUD.swift; sourceTree = "<group>"; };
|
||||||
@ -581,7 +579,6 @@
|
|||||||
CBAFCA1F2C0A10500054500E /* MP_AnalyticsManager.swift */,
|
CBAFCA1F2C0A10500054500E /* MP_AnalyticsManager.swift */,
|
||||||
CBAFCA202C0A10500054500E /* MP_AVURLAsset.swift */,
|
CBAFCA202C0A10500054500E /* MP_AVURLAsset.swift */,
|
||||||
CBAFCA212C0A10500054500E /* MP_CacheManager.swift */,
|
CBAFCA212C0A10500054500E /* MP_CacheManager.swift */,
|
||||||
CBAFCA222C0A10500054500E /* MP_CircularProgressView.swift */,
|
|
||||||
CBAFCA232C0A10500054500E /* MP_CoreDataHandlerManager.swift */,
|
CBAFCA232C0A10500054500E /* MP_CoreDataHandlerManager.swift */,
|
||||||
CBAFCA242C0A10500054500E /* MP_DownloadManager.swift */,
|
CBAFCA242C0A10500054500E /* MP_DownloadManager.swift */,
|
||||||
CBAFCA252C0A10500054500E /* MP_HUD.swift */,
|
CBAFCA252C0A10500054500E /* MP_HUD.swift */,
|
||||||
@ -1347,7 +1344,6 @@
|
|||||||
CBAFCB912C0A10500054500E /* MPSideA_HomeViewController.swift in Sources */,
|
CBAFCB912C0A10500054500E /* MPSideA_HomeViewController.swift in Sources */,
|
||||||
CBAFCAEA2C0A10500054500E /* MP_Lunch_ProgressView.swift in Sources */,
|
CBAFCAEA2C0A10500054500E /* MP_Lunch_ProgressView.swift in Sources */,
|
||||||
CBAFCB732C0A10500054500E /* MPPositive_SearchSuggestionItemTableViewCell.swift in Sources */,
|
CBAFCB732C0A10500054500E /* MPPositive_SearchSuggestionItemTableViewCell.swift in Sources */,
|
||||||
CBAFCB0B2C0A10500054500E /* MP_CircularProgressView.swift in Sources */,
|
|
||||||
CBAFCB432C0A10500054500E /* MPPositive_NavigationController.swift in Sources */,
|
CBAFCB432C0A10500054500E /* MPPositive_NavigationController.swift in Sources */,
|
||||||
CBAFCB302C0A10500054500E /* MPPositive_BrowseModuleListViewModel.swift in Sources */,
|
CBAFCB302C0A10500054500E /* MPPositive_BrowseModuleListViewModel.swift in Sources */,
|
||||||
CBAFCBA62C0A10500054500E /* MPSideA_Home_SecondListCollectionViewCell.swift in Sources */,
|
CBAFCBA62C0A10500054500E /* MPSideA_Home_SecondListCollectionViewCell.swift in Sources */,
|
||||||
@ -1470,7 +1466,7 @@
|
|||||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||||
COPY_PHASE_STRIP = NO;
|
COPY_PHASE_STRIP = NO;
|
||||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||||
ENABLE_TESTABILITY = YES;
|
ENABLE_TESTABILITY = YES;
|
||||||
ENABLE_USER_SCRIPT_SANDBOXING = NO;
|
ENABLE_USER_SCRIPT_SANDBOXING = NO;
|
||||||
@ -1565,7 +1561,7 @@
|
|||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
CURRENT_PROJECT_VERSION = 1.0.4.1;
|
CURRENT_PROJECT_VERSION = 1.0.4.1;
|
||||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||||
DEVELOPMENT_TEAM = 8DQD6BV6H9;
|
DEVELOPMENT_TEAM = T93S37G27F;
|
||||||
GENERATE_INFOPLIST_FILE = YES;
|
GENERATE_INFOPLIST_FILE = YES;
|
||||||
INFOPLIST_FILE = relax.offline.mp3.music/Info.plist;
|
INFOPLIST_FILE = relax.offline.mp3.music/Info.plist;
|
||||||
INFOPLIST_KEY_CFBundleDisplayName = Musiclax;
|
INFOPLIST_KEY_CFBundleDisplayName = Musiclax;
|
||||||
@ -1606,7 +1602,7 @@
|
|||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
CURRENT_PROJECT_VERSION = 1.0.4.1;
|
CURRENT_PROJECT_VERSION = 1.0.4.1;
|
||||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||||
DEVELOPMENT_TEAM = 8DQD6BV6H9;
|
DEVELOPMENT_TEAM = T93S37G27F;
|
||||||
GENERATE_INFOPLIST_FILE = YES;
|
GENERATE_INFOPLIST_FILE = YES;
|
||||||
INFOPLIST_FILE = relax.offline.mp3.music/Info.plist;
|
INFOPLIST_FILE = relax.offline.mp3.music/Info.plist;
|
||||||
INFOPLIST_KEY_CFBundleDisplayName = Musiclax;
|
INFOPLIST_KEY_CFBundleDisplayName = Musiclax;
|
||||||
|
|||||||
@ -18,14 +18,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
|||||||
// 用来保存由系统提供的完成处理器
|
// 用来保存由系统提供的完成处理器
|
||||||
var backgroundSessionCompletionHandler: (() -> Void)?
|
var backgroundSessionCompletionHandler: (() -> Void)?
|
||||||
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
|
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
|
||||||
//请求通知权限
|
|
||||||
UNUserNotificationCenter.current()
|
|
||||||
.requestAuthorization(options: [.alert, .sound, .badge]) {
|
|
||||||
(accepted, error) in
|
|
||||||
if !accepted {
|
|
||||||
print("Users are not allowed to be notified of messages.")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//生成一个FireBase实例
|
//生成一个FireBase实例
|
||||||
FirebaseApp.configure()
|
FirebaseApp.configure()
|
||||||
//启动前销毁所有的下载任务
|
//启动前销毁所有的下载任务
|
||||||
@ -39,8 +31,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
|||||||
switch_lunch()
|
switch_lunch()
|
||||||
//执行用户启动事件日志
|
//执行用户启动事件日志
|
||||||
MP_AnalyticsManager.shared.user_launchAction()
|
MP_AnalyticsManager.shared.user_launchAction()
|
||||||
// let numbers = [0]
|
|
||||||
// let _ = numbers[1]
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
func application(_ application: UIApplication, handleEventsForBackgroundURLSession identifier: String, completionHandler: @escaping () -> Void) {
|
func application(_ application: UIApplication, handleEventsForBackgroundURLSession identifier: String, completionHandler: @escaping () -> Void) {
|
||||||
@ -56,7 +46,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
|||||||
let session = AVAudioSession.sharedInstance()
|
let session = AVAudioSession.sharedInstance()
|
||||||
do {
|
do {
|
||||||
//允许后台活跃,播放以及记录
|
//允许后台活跃,播放以及记录
|
||||||
try session.setCategory(.playAndRecord, mode: .default)
|
try session.setCategory(.playAndRecord, mode: .default, options: [.allowAirPlay, .defaultToSpeaker])
|
||||||
//激活会话
|
//激活会话
|
||||||
try session.setActive(true)
|
try session.setActive(true)
|
||||||
try session.overrideOutputAudioPort(.speaker)
|
try session.overrideOutputAudioPort(.speaker)
|
||||||
|
|||||||
22
relax.offline.mp3.music/Assets.xcassets/Positive/Player/NoNetReache'log.imageset/Contents.json
vendored
Normal file
22
relax.offline.mp3.music/Assets.xcassets/Positive/Player/NoNetReache'log.imageset/Contents.json
vendored
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"images" : [
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename" : "img_v3_02bi_4e2abf4f-00e4-4e5f-9ed0-066d53fd191g.png",
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename" : "img_v3_02bi_7d70335a-d60e-4199-bafe-d683a83952fg.png",
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "3x"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"info" : {
|
||||||
|
"author" : "xcode",
|
||||||
|
"version" : 1
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 3.4 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 5.2 KiB |
@ -6,7 +6,6 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
class MP_BaseViewController: UIViewController {
|
class MP_BaseViewController: UIViewController {
|
||||||
|
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
@ -17,6 +16,73 @@ class MP_BaseViewController: UIViewController {
|
|||||||
tabBarController?.tabBar.isTranslucent = true
|
tabBarController?.tabBar.isTranslucent = true
|
||||||
//隐藏导航栏
|
//隐藏导航栏
|
||||||
navigationController?.setNavigationBarHidden(true, animated: false)
|
navigationController?.setNavigationBarHidden(true, animated: false)
|
||||||
|
// MP_NetWorkManager.shared.requestStatusToYouTube()
|
||||||
|
// 注册应用从后台唤醒到前台的通知
|
||||||
|
// NotificationCenter.default.addObserver(self, selector: #selector(appWillEnterForegroundAction), name:UIApplication.willEnterForegroundNotification, object: nil)
|
||||||
|
|
||||||
|
}
|
||||||
|
//前台通知
|
||||||
|
@objc private func appWillEnterForegroundAction() {
|
||||||
|
//检测当前状态是否拥有网络权限
|
||||||
|
guard MP_NetWorkManager.shared.netWorkStatu != .reachable else {
|
||||||
|
//当前网络正常状态
|
||||||
|
return
|
||||||
|
}
|
||||||
|
//当前网络不可用,检查是否手动触发过
|
||||||
|
guard UserDefaults.standard.bool(forKey: "isNetWorkUsage") != true else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
//保存手动触发状态
|
||||||
|
UserDefaults.standard.set(true, forKey: "isNetWorkUsage")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// private func triggerLocalNetworkPrivacyAlert() {
|
||||||
|
// let sock4 = socket(AF_INET, SOCK_DGRAM, 0)
|
||||||
|
// guard sock4 >= 0 else { return }
|
||||||
|
// defer { close(sock4) }
|
||||||
|
// let sock6 = socket(AF_INET6, SOCK_DGRAM, 0)
|
||||||
|
// guard sock6 >= 0 else { return }
|
||||||
|
// defer { close(sock6) }
|
||||||
|
//
|
||||||
|
// let addresses = addressesOfDiscardServiceOnBroadcastCapableInterfaces()
|
||||||
|
// var message = [UInt8]("!".utf8)
|
||||||
|
// for address in addresses {
|
||||||
|
// address.withUnsafeBytes { buf in
|
||||||
|
// let sa = buf.baseAddress!.assumingMemoryBound(to: sockaddr.self)
|
||||||
|
// let saLen = socklen_t(buf.count)
|
||||||
|
// let sock = sa.pointee.sa_family == AF_INET ? sock4 : sock6
|
||||||
|
// _ = sendto(sock, &message, message.count, MSG_DONTWAIT, sa, saLen)
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// private func addressesOfDiscardServiceOnBroadcastCapableInterfaces() -> [Data] {
|
||||||
|
// var addrList: UnsafeMutablePointer<ifaddrs>? = nil
|
||||||
|
// let err = getifaddrs(&addrList)
|
||||||
|
// guard err == 0, let start = addrList else { return [] }
|
||||||
|
// defer { freeifaddrs(start) }
|
||||||
|
// return sequence(first: start, next: { $0.pointee.ifa_next })
|
||||||
|
// .compactMap { i -> Data? in
|
||||||
|
// guard(i.pointee.ifa_flags & UInt32(bitPattern: IFF_BROADCAST)) != 0,
|
||||||
|
// let sa = i.pointee.ifa_addr
|
||||||
|
// else { return nil }
|
||||||
|
// var result = Data(UnsafeRawBufferPointer(start: sa, count: Int(sa.pointee.sa_len)))
|
||||||
|
// switch CInt(sa.pointee.sa_family) {
|
||||||
|
// case AF_INET:
|
||||||
|
// result.withUnsafeMutableBytes { buf in
|
||||||
|
// let sin = buf.baseAddress!.assumingMemoryBound(to: sockaddr_in.self)
|
||||||
|
// sin.pointee.sin_port = UInt16(9).bigEndian
|
||||||
|
// }
|
||||||
|
// case AF_INET6:
|
||||||
|
// result.withUnsafeMutableBytes { buf in
|
||||||
|
// let sin6 = buf.baseAddress!.assumingMemoryBound(to: sockaddr_in6.self)
|
||||||
|
// sin6.pointee.sin6_port = UInt16(9).bigEndian
|
||||||
|
// }
|
||||||
|
// default:
|
||||||
|
// return nil
|
||||||
|
// }
|
||||||
|
// return result
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,68 +26,9 @@ class MP_LunchViewController: UIViewController {
|
|||||||
view.backgroundColor = .init(hex: "#000000")
|
view.backgroundColor = .init(hex: "#000000")
|
||||||
timer = CADisplayLink(target: self, selector: #selector(timerActionClick(_ :)))
|
timer = CADisplayLink(target: self, selector: #selector(timerActionClick(_ :)))
|
||||||
//一秒执行多少次
|
//一秒执行多少次
|
||||||
timer.preferredFramesPerSecond = 20
|
timer.preferredFramesPerSecond = 40
|
||||||
//开辟线程
|
//开辟线程
|
||||||
timer.add(to: RunLoop.current, forMode: .common)
|
timer.add(to: RunLoop.current, forMode: .common)
|
||||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
|
|
||||||
[weak self] in
|
|
||||||
guard let self = self else {return}
|
|
||||||
requestTrackingAuthorization { idfa in
|
|
||||||
if let idfa = idfa {
|
|
||||||
print("用户同意授权-idfa:\(idfa)")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
MP_AnalyticsManager.shared.getOpenStatus { [weak self] open in
|
|
||||||
guard let self = self else {return}
|
|
||||||
if open {
|
|
||||||
//根据ip值确定进入那个页面
|
|
||||||
MP_NetWorkManager.shared.requestIPInfo { statu in
|
|
||||||
if statu == true {
|
|
||||||
//允许进入b面
|
|
||||||
print("BLog")
|
|
||||||
self.completionBlock = {
|
|
||||||
DispatchQueue.main.async {
|
|
||||||
[weak self] in
|
|
||||||
guard let self = self else {return}
|
|
||||||
//停止计时器
|
|
||||||
timer.isPaused = true
|
|
||||||
//加载完毕,判断并跳转
|
|
||||||
accessAppdelegate.switch_positive()
|
|
||||||
//获取首页
|
|
||||||
MPPositive_BrowseLoadViewModel.shared.reloadBrowseLists()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}else {
|
|
||||||
print("ALog")
|
|
||||||
//打开A面
|
|
||||||
self.completionBlock = {
|
|
||||||
DispatchQueue.main.async {
|
|
||||||
[weak self] in
|
|
||||||
guard let self = self else {return}
|
|
||||||
//停止计时器
|
|
||||||
timer.isPaused = true
|
|
||||||
//加载完毕,判断并跳转
|
|
||||||
accessAppdelegate.switch_aSide()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}else {
|
|
||||||
print("ALog")
|
|
||||||
//打开A面
|
|
||||||
completionBlock = {
|
|
||||||
DispatchQueue.main.async {
|
|
||||||
[weak self] in
|
|
||||||
guard let self = self else {return}
|
|
||||||
//停止计时器
|
|
||||||
timer.isPaused = true
|
|
||||||
//加载完毕,判断并跳转
|
|
||||||
accessAppdelegate.switch_aSide()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//启动计时器
|
//启动计时器
|
||||||
timer.isPaused = false
|
timer.isPaused = false
|
||||||
// self.completionBlock = {
|
// self.completionBlock = {
|
||||||
@ -109,6 +50,21 @@ class MP_LunchViewController: UIViewController {
|
|||||||
timer = nil
|
timer = nil
|
||||||
NotificationCenter.default.removeObserver(self)
|
NotificationCenter.default.removeObserver(self)
|
||||||
}
|
}
|
||||||
|
override func viewDidAppear(_ animated: Bool) {
|
||||||
|
super.viewDidAppear(animated)
|
||||||
|
DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
|
||||||
|
// 请求跟踪授权
|
||||||
|
requestTrackingAuthorization { idfa in
|
||||||
|
// if let idfa = idfa {
|
||||||
|
// print("IDFA: \(idfa)")
|
||||||
|
// StartManager.shared.idfaid = idfa
|
||||||
|
// print("Stored IDFA: \(StartManager.shared.idfaid ?? "N/A")")
|
||||||
|
// } else {
|
||||||
|
// print("IDFA is not available or tracking authorization denied.")
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
override func viewWillDisappear(_ animated: Bool) {
|
override func viewWillDisappear(_ animated: Bool) {
|
||||||
super.viewWillDisappear(animated)
|
super.viewWillDisappear(animated)
|
||||||
MP_AnalyticsManager.shared.launch_pvAction()
|
MP_AnalyticsManager.shared.launch_pvAction()
|
||||||
@ -118,7 +74,7 @@ class MP_LunchViewController: UIViewController {
|
|||||||
@objc fileprivate func timerActionClick(_ link:CADisplayLink) {
|
@objc fileprivate func timerActionClick(_ link:CADisplayLink) {
|
||||||
if maxTimes > currentTimes {
|
if maxTimes > currentTimes {
|
||||||
//未加载完
|
//未加载完
|
||||||
currentTimes += 0.05
|
currentTimes += 0.025
|
||||||
let value = currentTimes/maxTimes
|
let value = currentTimes/maxTimes
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
[weak self] in
|
[weak self] in
|
||||||
@ -127,8 +83,51 @@ class MP_LunchViewController: UIViewController {
|
|||||||
progressView.setProgress(value)
|
progressView.setProgress(value)
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
if completionBlock != nil {
|
//停止计时器
|
||||||
completionBlock!()
|
timer.isPaused = true
|
||||||
|
MP_AnalyticsManager.shared.getOpenStatus { [weak self] open in
|
||||||
|
guard let self = self else {return}
|
||||||
|
if open {
|
||||||
|
//根据ip值确定进入那个页面
|
||||||
|
MP_NetWorkManager.shared.requestIPInfo { statu in
|
||||||
|
if statu == true {
|
||||||
|
//允许进入b面
|
||||||
|
print("BLog")
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
[weak self] in
|
||||||
|
guard let self = self else {return}
|
||||||
|
//停止计时器
|
||||||
|
timer.isPaused = true
|
||||||
|
//加载完毕,判断并跳转
|
||||||
|
accessAppdelegate.switch_positive()
|
||||||
|
//获取首页
|
||||||
|
MPPositive_BrowseLoadViewModel.shared.reloadBrowseLists()
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
print("ALog")
|
||||||
|
//打开A面
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
[weak self] in
|
||||||
|
guard let self = self else {return}
|
||||||
|
//停止计时器
|
||||||
|
timer.isPaused = true
|
||||||
|
//加载完毕,判断并跳转
|
||||||
|
accessAppdelegate.switch_aSide()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
print("ALog")
|
||||||
|
//打开A面
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
[weak self] in
|
||||||
|
guard let self = self else {return}
|
||||||
|
//停止计时器
|
||||||
|
timer.isPaused = true
|
||||||
|
//加载完毕,判断并跳转
|
||||||
|
accessAppdelegate.switch_aSide()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -107,14 +107,14 @@ func improveDataforResouceAndCover(_ song:MPPositive_SongItemModel, completion:@
|
|||||||
///转时分值
|
///转时分值
|
||||||
func setTimesToMinSeconds(_ time:TimeInterval) -> String {
|
func setTimesToMinSeconds(_ time:TimeInterval) -> String {
|
||||||
//设置分钟
|
//设置分钟
|
||||||
let min = Int(time / 60)
|
let min = Int((time.isNaN ? 0:time) / 60)
|
||||||
let second = Int(time.truncatingRemainder(dividingBy: 60))
|
let second = Int((time.isNaN ? 0:time).truncatingRemainder(dividingBy: 60))
|
||||||
return "\(min < 10 ? "0\(min)":"\(min)"):\(second < 10 ? "0\(second)":"\(second)")"
|
return "\(min < 10 ? "0\(min)":"\(min)"):\(second < 10 ? "0\(second)":"\(second)")"
|
||||||
}
|
}
|
||||||
///转分值
|
///转分值
|
||||||
func setTimesToMins(_ time:TimeInterval) -> String {
|
func setTimesToMins(_ time:TimeInterval) -> String {
|
||||||
//设置分钟
|
//设置分钟
|
||||||
let min = Int(time / 60)
|
let min = Int((time.isNaN ? 0:time) / 60)
|
||||||
return "\(min < 10 ? "0\(min)":"\(min)")"
|
return "\(min < 10 ? "0\(min)":"\(min)")"
|
||||||
}
|
}
|
||||||
///获取麦克风权限
|
///获取麦克风权限
|
||||||
@ -219,3 +219,25 @@ func requestTrackingAuthorization(completion: @escaping (String?) -> Void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
///截取\n\n后续的文本
|
||||||
|
func truncateTextAfterTwoNewlines(from text: String) -> String {
|
||||||
|
// 定义正则表达式,匹配两个连续的换行符及其之后的内容
|
||||||
|
let pattern = "\n{2,}.*"
|
||||||
|
let regex = try! NSRegularExpression(pattern: pattern, options: [.dotMatchesLineSeparators])
|
||||||
|
|
||||||
|
// 使用正则表达式进行替换,删除匹配到的部分
|
||||||
|
let truncatedText = regex.stringByReplacingMatches(in: text, options: [], range: NSRange(location: 0, length: text.utf16.count), withTemplate: "")
|
||||||
|
|
||||||
|
return truncatedText
|
||||||
|
}
|
||||||
|
///获取通知请求权限
|
||||||
|
func getUserNotificationCenter() {
|
||||||
|
//请求通知权限
|
||||||
|
UNUserNotificationCenter.current()
|
||||||
|
.requestAuthorization(options: [.alert, .sound, .badge]) {
|
||||||
|
(accepted, error) in
|
||||||
|
if !accepted {
|
||||||
|
print("Users are not allowed to be notified of messages.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -15,7 +15,7 @@ class MPPositive_Debouncer: NSObject {
|
|||||||
private var delay: TimeInterval
|
private var delay: TimeInterval
|
||||||
|
|
||||||
private override init() {
|
private override init() {
|
||||||
delay = 0.2
|
delay = 0.1
|
||||||
super.init()
|
super.init()
|
||||||
}
|
}
|
||||||
deinit {
|
deinit {
|
||||||
|
|||||||
@ -1,84 +0,0 @@
|
|||||||
//
|
|
||||||
// MP_CircularProgressView.swift
|
|
||||||
// MusicPlayer
|
|
||||||
//
|
|
||||||
// Created by 忆海16 on 2024/5/14.
|
|
||||||
//
|
|
||||||
|
|
||||||
import Foundation
|
|
||||||
import UIKit
|
|
||||||
|
|
||||||
class CircularProgressView: UIView {
|
|
||||||
|
|
||||||
private var progressLayer = CAShapeLayer()
|
|
||||||
private var trackLayer = CAShapeLayer()
|
|
||||||
public var progress: CGFloat = 0 {
|
|
||||||
didSet {
|
|
||||||
progressLayer.strokeEnd = progress
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override init(frame: CGRect) {
|
|
||||||
super.init(frame: frame)
|
|
||||||
setupView()
|
|
||||||
}
|
|
||||||
|
|
||||||
required init?(coder: NSCoder) {
|
|
||||||
super.init(coder: coder)
|
|
||||||
setupView()
|
|
||||||
}
|
|
||||||
|
|
||||||
// private func setupLayers() {
|
|
||||||
// // Track layer (background circle)
|
|
||||||
// let center = CGPoint(x: bounds.width / 2, y: bounds.height / 2)
|
|
||||||
// let circularPath = UIBezierPath(arcCenter: center, radius: bounds.width / 2, startAngle: -CGFloat.pi / 2, endAngle: 3 * CGFloat.pi / 2, clockwise: true)
|
|
||||||
//
|
|
||||||
// trackLayer.path = circularPath.cgPath
|
|
||||||
// trackLayer.strokeColor = UIColor.lightGray.cgColor
|
|
||||||
// trackLayer.lineWidth = 3
|
|
||||||
// trackLayer.fillColor = UIColor.clear.cgColor
|
|
||||||
// layer.addSublayer(trackLayer)
|
|
||||||
//
|
|
||||||
// // Progress layer (foreground circle)
|
|
||||||
// progressLayer.path = circularPath.cgPath
|
|
||||||
// progressLayer.strokeColor = UIColor.green.cgColor
|
|
||||||
// progressLayer.lineWidth = 3
|
|
||||||
// progressLayer.fillColor = UIColor.clear.cgColor
|
|
||||||
// progressLayer.lineCap = .round
|
|
||||||
// progressLayer.strokeEnd = 0
|
|
||||||
// layer.addSublayer(progressLayer)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// func setProgress(to progress: CGFloat) {
|
|
||||||
// self.progress = progress
|
|
||||||
// }
|
|
||||||
private func setupView() {
|
|
||||||
// 设置轨道图层
|
|
||||||
trackLayer.path = createCircularPath().cgPath
|
|
||||||
trackLayer.fillColor = UIColor.clear.cgColor
|
|
||||||
trackLayer.strokeColor = UIColor.lightGray.cgColor
|
|
||||||
trackLayer.lineWidth = 3
|
|
||||||
trackLayer.strokeEnd = 1.0
|
|
||||||
layer.addSublayer(trackLayer)
|
|
||||||
|
|
||||||
// 设置进度图层
|
|
||||||
progressLayer.path = createCircularPath().cgPath
|
|
||||||
progressLayer.fillColor = UIColor.clear.cgColor
|
|
||||||
progressLayer.strokeColor = UIColor.green.cgColor
|
|
||||||
progressLayer.lineWidth = 3
|
|
||||||
progressLayer.strokeEnd = 0.0
|
|
||||||
layer.addSublayer(progressLayer)
|
|
||||||
}
|
|
||||||
|
|
||||||
private func createCircularPath() -> UIBezierPath {
|
|
||||||
return UIBezierPath(arcCenter: center, radius: bounds.size.width / 2, startAngle: -.pi / 2, endAngle: .pi * 3 / 2, clockwise: true)
|
|
||||||
}
|
|
||||||
|
|
||||||
func setProgress(to progress: CGFloat) {
|
|
||||||
self.progress = progress
|
|
||||||
print("Updating progress to: \(progress)")
|
|
||||||
DispatchQueue.main.async {
|
|
||||||
self.progressLayer.strokeEnd = progress
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -65,19 +65,20 @@ class MP_HUD: NSObject {
|
|||||||
static func showWithStatus(hudStatus status: status, text: String?, delay: TimeInterval ,completion:(() -> Void)?) {
|
static func showWithStatus(hudStatus status: status, text: String?, delay: TimeInterval ,completion:(() -> Void)?) {
|
||||||
SVProgressHUD.setDefaultStyle(.light)
|
SVProgressHUD.setDefaultStyle(.light)
|
||||||
SVProgressHUD.setDefaultMaskType(.clear)
|
SVProgressHUD.setDefaultMaskType(.clear)
|
||||||
SVProgressHUD.setBackgroundColor(.init(hex: "#80F988", alpha: 0.1))
|
SVProgressHUD.setBackgroundColor(.init(hex: "#151718", alpha: 0.4))
|
||||||
SVProgressHUD.setForegroundColor(.init(hex: "#80F988"))
|
SVProgressHUD.setForegroundColor(.white)
|
||||||
SVProgressHUD.setOffsetFromCenter(.init(horizontal: 0, vertical: 0))
|
SVProgressHUD.setOffsetFromCenter(.init(horizontal: 0, vertical: 0))
|
||||||
switch status {
|
switch status {
|
||||||
case .success:
|
case .success:
|
||||||
SVProgressHUD.showSuccess(withStatus: text)
|
SVProgressHUD.showSuccess(withStatus: text)
|
||||||
SVProgressHUD.setMinimumSize(CGSize(width: 100 * width, height: 80 * width))
|
SVProgressHUD.setMinimumSize(CGSize(width: 100 * width, height: 80 * width))
|
||||||
|
SVProgressHUD.show(UIImage(), status: text)
|
||||||
case .error:
|
case .error:
|
||||||
SVProgressHUD.showError(withStatus: text)
|
SVProgressHUD.showError(withStatus: text)
|
||||||
case .onlyText:
|
case .onlyText:
|
||||||
SVProgressHUD.setOffsetFromCenter(.init(horizontal: 0, vertical: (screen_Height / 2) - 85 * width))
|
// SVProgressHUD.setOffsetFromCenter(.init(horizontal: 0, vertical: (screen_Height / 2) - 85 * width))
|
||||||
SVProgressHUD.setMinimumSize(CGSize(width: 100 * width, height: 40 * width))
|
SVProgressHUD.setMinimumSize(CGSize(width: 100 * width, height: 40 * width))
|
||||||
SVProgressHUD.show(UIImage(), status: text)
|
SVProgressHUD.show(UIImage(named: "NoNetReache'log")!, status: text)
|
||||||
case .loading:
|
case .loading:
|
||||||
SVProgressHUD.setBackgroundColor(.white)
|
SVProgressHUD.setBackgroundColor(.white)
|
||||||
SVProgressHUD.show()
|
SVProgressHUD.show()
|
||||||
|
|||||||
@ -63,16 +63,16 @@ class MP_NetWorkManager: NSObject {
|
|||||||
private let youTubeKeys:[String] = ["MUSIC_VIDEO_TYPE_ATV","MUSIC_VIDEO_TYPE_OMV","MUSIC_PAGE_TYPE_ALBUM","MUSIC_PAGE_TYPE_ARTIST","MUSIC_PAGE_TYPE_PLAYLIST","MUSIC_PAGE_TYPE_TRACK_LYRICS","MUSIC_PAGE_TYPE_TRACK_RELATED"]
|
private let youTubeKeys:[String] = ["MUSIC_VIDEO_TYPE_ATV","MUSIC_VIDEO_TYPE_OMV","MUSIC_PAGE_TYPE_ALBUM","MUSIC_PAGE_TYPE_ARTIST","MUSIC_PAGE_TYPE_PLAYLIST","MUSIC_PAGE_TYPE_TRACK_LYRICS","MUSIC_PAGE_TYPE_TRACK_RELATED"]
|
||||||
///禁止接入IP信息组
|
///禁止接入IP信息组
|
||||||
private let banIPs:[String] = [
|
private let banIPs:[String] = [
|
||||||
// "CN",
|
"CN",
|
||||||
// "HK",
|
"HK",
|
||||||
// "TW",
|
"TW",
|
||||||
// "JP",
|
"JP",
|
||||||
// "KR",
|
"KR",
|
||||||
// "GB",
|
"GB",
|
||||||
// "CH",
|
"CH",
|
||||||
// "BE",
|
"BE",
|
||||||
// "MO",
|
"MO",
|
||||||
// "SG"
|
"SG"
|
||||||
]
|
]
|
||||||
//网络状态
|
//网络状态
|
||||||
enum NetWorkStatus: String {
|
enum NetWorkStatus: String {
|
||||||
@ -82,22 +82,33 @@ class MP_NetWorkManager: NSObject {
|
|||||||
}
|
}
|
||||||
///网络监听器
|
///网络监听器
|
||||||
private let reachabilityManager:NetworkReachabilityManager = NetworkReachabilityManager(host: "https://music.youtube.com/")!
|
private let reachabilityManager:NetworkReachabilityManager = NetworkReachabilityManager(host: "https://music.youtube.com/")!
|
||||||
|
///网络监听器
|
||||||
|
private var monitor:NWPathMonitor
|
||||||
|
///对监听器的判断
|
||||||
|
private var isReach:Bool = false
|
||||||
///当前网络状态
|
///当前网络状态
|
||||||
var netWorkStatu:NetWorkStatus!{
|
var netWorkStatu:NetWorkStatus!{
|
||||||
willSet{
|
willSet{
|
||||||
//旧值为网络可用,新值为网络不可用,为断网第一时间,发出通知告知播放器
|
guard newValue != netWorkStatu else {
|
||||||
if netWorkStatu == .reachable, newValue == .notReachable {
|
//重复情况
|
||||||
print("网络不可用")
|
return
|
||||||
NotificationCenter.notificationKey.post(notificationName: .net_switch_notReachable)
|
|
||||||
}
|
}
|
||||||
//旧值为网络不可用,新值为网络可用,为网络回复第一时间,发出通知告知播放器
|
switch newValue {
|
||||||
if (netWorkStatu == .notReachable), newValue == .reachable {
|
case .reachable://网络可用
|
||||||
print("网络可用")
|
print("网络可用")
|
||||||
NotificationCenter.notificationKey.post(notificationName: .net_switch_reachable)
|
NotificationCenter.notificationKey.post(notificationName: .net_switch_reachable)
|
||||||
|
case .notReachable://不可用
|
||||||
|
print("网络不可用")
|
||||||
|
NotificationCenter.notificationKey.post(notificationName: .net_switch_notReachable)
|
||||||
|
case .unknown://位置情况
|
||||||
|
print("网络状况未知")
|
||||||
|
case .none:
|
||||||
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//避免连续切换网络状态计时器
|
||||||
|
private var debounceTimer: Timer?
|
||||||
//MARK: - 固定参数
|
//MARK: - 固定参数
|
||||||
//访问数据(首次首页预览时获得)
|
//访问数据(首次首页预览时获得)
|
||||||
private var visitorData:String?
|
private var visitorData:String?
|
||||||
@ -154,63 +165,97 @@ class MP_NetWorkManager: NSObject {
|
|||||||
var browseRequestStateBlock:BrowseRequestStateBlock?
|
var browseRequestStateBlock:BrowseRequestStateBlock?
|
||||||
//私有初始化
|
//私有初始化
|
||||||
private override init() {
|
private override init() {
|
||||||
|
self.monitor = NWPathMonitor()
|
||||||
super.init()
|
super.init()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//MARK: - 网络情况
|
//MARK: - 网络情况
|
||||||
///检查网络状况
|
///检查网络状况
|
||||||
func requestNetworkPermission(oberve:UIViewController, completeHanlder:ActionBlock?) {
|
func requestNetworkPermission(oberve:UIViewController, completeHanlder:ActionBlock?) {
|
||||||
let monitor = NWPathMonitor()
|
let monitor = NWPathMonitor()
|
||||||
monitor.pathUpdateHandler = { path in
|
switch netWorkStatu {
|
||||||
switch path.status {
|
case .reachable:
|
||||||
case .satisfied:
|
DispatchQueue.main.async {
|
||||||
DispatchQueue.main.async {
|
guard completeHanlder != nil else {
|
||||||
guard completeHanlder != nil else {
|
return
|
||||||
return
|
|
||||||
}
|
|
||||||
completeHanlder!()
|
|
||||||
}
|
}
|
||||||
default://网络权限出现问题
|
completeHanlder!()
|
||||||
DispatchQueue.main.async {
|
}
|
||||||
//次要处理
|
default:
|
||||||
let alertController = UIAlertController(title: "Access network request", message: "”Musiclax“ needs to be loaded via a network request. Please click “Settings” to allow this application to gain access to the network.", preferredStyle: .alert)
|
DispatchQueue.main.async {
|
||||||
let CancelAction = UIAlertAction(title:"Cancel", style: .cancel) { (Cancel) in
|
//次要处理
|
||||||
|
let alertController = UIAlertController(title: "Access network request", message: "”Musiclax“ needs to be loaded via a network request. Please click “Settings” to allow this application to gain access to the network.", preferredStyle: .alert)
|
||||||
|
let CancelAction = UIAlertAction(title:"Cancel", style: .cancel) { (Cancel) in
|
||||||
|
|
||||||
}
|
}
|
||||||
let OKAction = UIAlertAction(title: "Settings", style: .default) { (action) in
|
let OKAction = UIAlertAction(title: "Settings", style: .default) { (action) in
|
||||||
let url = URL(string: UIApplication.openSettingsURLString)
|
let url = URL(string: UIApplication.openSettingsURLString)
|
||||||
if let url = url,UIApplication.shared.canOpenURL(url){
|
if let url = url,UIApplication.shared.canOpenURL(url){
|
||||||
if #available(iOS 10, *) {
|
if #available(iOS 10, *) {
|
||||||
UIApplication.shared.open(url, options: [:]) { (success) in
|
UIApplication.shared.open(url, options: [:]) { (success) in
|
||||||
}
|
|
||||||
}else{
|
|
||||||
UIApplication.shared.canOpenURL(url)
|
|
||||||
}
|
}
|
||||||
|
}else{
|
||||||
|
UIApplication.shared.canOpenURL(url)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
alertController.addAction(CancelAction)
|
|
||||||
alertController.addAction(OKAction)
|
|
||||||
oberve.present(alertController, animated: true, completion: nil)
|
|
||||||
}
|
}
|
||||||
|
alertController.addAction(CancelAction)
|
||||||
|
alertController.addAction(OKAction)
|
||||||
|
oberve.present(alertController, animated: true, completion: nil)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let queue = DispatchQueue(label: "MPNetWorkManager")
|
|
||||||
monitor.start(queue: queue)
|
|
||||||
}
|
}
|
||||||
///网络请求检测
|
///网络请求检测
|
||||||
func requestStatusToYouTube() {
|
func requestStatusToYouTube() {
|
||||||
//通过ping节点确认是否能执行网络请求
|
guard isReach == false else {
|
||||||
reachabilityManager.startListening(onQueue: .main, onUpdatePerforming: { [weak self] status in
|
return
|
||||||
guard let self = self else {return}
|
}
|
||||||
switch status {
|
isReach = true
|
||||||
case .unknown://未知状况
|
// //通过ping节点确认是否能执行网络请求
|
||||||
netWorkStatu = .unknown
|
// reachabilityManager.startListening(onQueue: .main, onUpdatePerforming: { [weak self] status in
|
||||||
case .notReachable://网络不可用
|
// guard let self = self else {return}
|
||||||
netWorkStatu = .notReachable
|
// var newStatu:NetWorkStatus = .unknown
|
||||||
case .reachable(.ethernetOrWiFi), .reachable(.cellular)://网络可用,且做出了分类
|
// switch status {
|
||||||
netWorkStatu = .reachable
|
// case .unknown://未知状况
|
||||||
|
// newStatu = .unknown
|
||||||
|
// case .notReachable://网络不可用
|
||||||
|
// newStatu = .notReachable
|
||||||
|
// case .reachable(.ethernetOrWiFi), .reachable(.cellular)://网络可用,且做出了分类
|
||||||
|
// newStatu = .reachable
|
||||||
|
// }
|
||||||
|
// // 去抖处理,确保状态变化稳定后再更新
|
||||||
|
// self.handleDebouncedNetworkStatusChange(newStatu)
|
||||||
|
// })
|
||||||
|
let queue = DispatchQueue(label: "MPNetWorkManager")
|
||||||
|
monitor.start(queue: queue)
|
||||||
|
monitor.pathUpdateHandler = { [weak self] path in
|
||||||
|
self?.updateNetworkStatus(path)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private func updateNetworkStatus(_ path: NWPath) {
|
||||||
|
if path.status == .satisfied {
|
||||||
|
netWorkStatu = .reachable
|
||||||
|
} else {
|
||||||
|
netWorkStatu = .notReachable
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func stopListening() {
|
||||||
|
reachabilityManager.stopListening()
|
||||||
|
isReach = false
|
||||||
|
}
|
||||||
|
private func handleDebouncedNetworkStatusChange(_ newStatus: NetWorkStatus) {
|
||||||
|
// 取消之前的去抖操作
|
||||||
|
debounceTimer?.invalidate()
|
||||||
|
// 设置新的去抖操作
|
||||||
|
debounceTimer = Timer.scheduledTimer(withTimeInterval: 1.0, repeats: false) { [weak self] _ in
|
||||||
|
guard let self = self else { return }
|
||||||
|
// 更新状态时只在去抖时间窗口后处理变化
|
||||||
|
if newStatus != self.netWorkStatu {
|
||||||
|
self.netWorkStatu = newStatus
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//MARK: - API请求
|
//MARK: - API请求
|
||||||
@ -1238,7 +1283,8 @@ extension MP_NetWorkManager {
|
|||||||
model.subscriptions = header.musicImmersiveHeaderRenderer?.subscriptionButton?.subscribeButtonRenderer?.subscriberCountText?.runs?.reduce("", { $0 + ($1.text ?? "")})
|
model.subscriptions = header.musicImmersiveHeaderRenderer?.subscriptionButton?.subscribeButtonRenderer?.subscriberCountText?.runs?.reduce("", { $0 + ($1.text ?? "")})
|
||||||
model.subscriptionedText = header.musicImmersiveHeaderRenderer?.subscriptionButton?.subscribeButtonRenderer?.subscribedButtonText?.runs?.reduce("", { $0 + ($1.text ?? "")})
|
model.subscriptionedText = header.musicImmersiveHeaderRenderer?.subscriptionButton?.subscribeButtonRenderer?.subscribedButtonText?.runs?.reduce("", { $0 + ($1.text ?? "")})
|
||||||
model.fordescription = header.musicImmersiveHeaderRenderer?.description?.runs?.reduce("", { $0 + ($1.text ?? "")})
|
model.fordescription = header.musicImmersiveHeaderRenderer?.description?.runs?.reduce("", { $0 + ($1.text ?? "")})
|
||||||
model.thumbnails = header.musicImmersiveHeaderRenderer?.thumbnail?.musicThumbnailRenderer?.thumbnail?.thumbnails?.compactMap({$0.url})
|
model.fordescription = truncateTextAfterTwoNewlines(from: model.fordescription ?? "")
|
||||||
|
model.thumbnails = header.musicImmersiveHeaderRenderer?.thumbnail?.musicThumbnailRenderer?.thumbnail?.thumbnails?.compactMap({$0.url})
|
||||||
return model
|
return model
|
||||||
}
|
}
|
||||||
///解析艺术家_Contents
|
///解析艺术家_Contents
|
||||||
@ -1413,7 +1459,14 @@ extension MP_NetWorkManager {
|
|||||||
var videos:[String] = []
|
var videos:[String] = []
|
||||||
var itags:[Int] = []
|
var itags:[Int] = []
|
||||||
var mimeType:[String] = []
|
var mimeType:[String] = []
|
||||||
let allFormats = (streamingData.formats ?? []) + (streamingData.adaptiveFormats ?? [])
|
var allFormats = (streamingData.formats ?? []) + (streamingData.adaptiveFormats ?? [])
|
||||||
|
// //以itag进行排序(从大到小)
|
||||||
|
// allFormats = allFormats.sorted(by: {($0.itag ?? 0) > ($1.itag ?? 0)})
|
||||||
|
//取第一个mimeType包含(video/mp4)的资源
|
||||||
|
// if let index = allFormats.firstIndex(where: {$0.itag == 22}) {
|
||||||
|
// let element = allFormats.remove(at: index)
|
||||||
|
// allFormats.insert(element, at: 0)
|
||||||
|
// }
|
||||||
for format in allFormats {
|
for format in allFormats {
|
||||||
videos.append(format.url ?? "")
|
videos.append(format.url ?? "")
|
||||||
itags.append(format.itag ?? 0)
|
itags.append(format.itag ?? 0)
|
||||||
|
|||||||
@ -92,6 +92,7 @@ class MP_PlayerManager:NSObject{
|
|||||||
center?.pauseCommand.removeTarget(self)
|
center?.pauseCommand.removeTarget(self)
|
||||||
center?.nextTrackCommand.removeTarget(self)
|
center?.nextTrackCommand.removeTarget(self)
|
||||||
center?.previousTrackCommand.removeTarget(self)
|
center?.previousTrackCommand.removeTarget(self)
|
||||||
|
center?.changePlaybackPositionCommand.removeTarget(self)
|
||||||
center = nil
|
center = nil
|
||||||
do {
|
do {
|
||||||
try AVAudioSession.sharedInstance().setActive(false)
|
try AVAudioSession.sharedInstance().setActive(false)
|
||||||
@ -102,6 +103,8 @@ class MP_PlayerManager:NSObject{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//当前音乐的字典
|
||||||
|
private var currentInfo:[String:Any]?
|
||||||
//当前播放器状态
|
//当前播放器状态
|
||||||
private var playState:MP_PlayerStateType = .Null{
|
private var playState:MP_PlayerStateType = .Null{
|
||||||
didSet{
|
didSet{
|
||||||
@ -168,7 +171,8 @@ class MP_PlayerManager:NSObject{
|
|||||||
//转化为当前播放进度秒值
|
//转化为当前播放进度秒值
|
||||||
let currentDuration = CMTimeGetSeconds(time)
|
let currentDuration = CMTimeGetSeconds(time)
|
||||||
//更新控制中心的进度条
|
//更新控制中心的进度条
|
||||||
updateProgress(currentDuration)
|
// updateProgress(currentDuration)
|
||||||
|
updateNowPlayingInfo()
|
||||||
//获取当前播放音乐资源的最大时间值
|
//获取当前播放音乐资源的最大时间值
|
||||||
let maxDuration = getMusicDuration()
|
let maxDuration = getMusicDuration()
|
||||||
if maxDuration.isNaN == false {
|
if maxDuration.isNaN == false {
|
||||||
@ -282,25 +286,21 @@ class MP_PlayerManager:NSObject{
|
|||||||
if playState != .Playing {
|
if playState != .Playing {
|
||||||
//当statuVlaue值等于playerItem准备播放的值,说明已经准备好播放
|
//当statuVlaue值等于playerItem准备播放的值,说明已经准备好播放
|
||||||
print("当前音乐-\(loadPlayer?.currentVideo?.title ?? "") 已经准备好播放")
|
print("当前音乐-\(loadPlayer?.currentVideo?.title ?? "") 已经准备好播放")
|
||||||
// if playState != .Playing {
|
|
||||||
// player.play()
|
|
||||||
// playState = .Playing
|
|
||||||
// //暂停计时器,并获取延时值
|
|
||||||
// suspendTimer()
|
|
||||||
// let times = Int(self.times)
|
|
||||||
// let msTimes = times*1000
|
|
||||||
// MP_AnalyticsManager.shared.player_b_delay_actionAction(loadPlayer.currentVideo?.song.videoId ?? "", videoname: loadPlayer.currentVideo?.title ?? "", artistname: loadPlayer.currentVideo?.song.shortBylineText ?? "", delay: "\(msTimes)ms")
|
|
||||||
// MP_AnalyticsManager.shared.player_b_success_actionAction(loadPlayer.currentVideo?.song.videoId ?? "", videoname: loadPlayer.currentVideo?.title ?? "", artistname: loadPlayer.currentVideo?.song.shortBylineText ?? "")
|
|
||||||
// //执行开始播放闭包
|
|
||||||
// if startActionBlock != nil {
|
|
||||||
// startActionBlock!()
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
print("当前音乐-\(loadPlayer.currentVideo?.title ?? "") 未做好准备播放,失败原因是\(loadPlayer.currentVideo?.resourcePlayerItem.error?.localizedDescription ?? "")")
|
print("当前音乐-\(loadPlayer.currentVideo?.title ?? "") 未做好准备播放,失败原因是\(loadPlayer.currentVideo?.resourcePlayerItem.error?.localizedDescription ?? "")")
|
||||||
//重新
|
if loadPlayer?.currentVideo?.isKVO == true {
|
||||||
play()
|
//切歌时移除KVO监听
|
||||||
|
loadPlayer?.currentVideo?.resourcePlayerItem.removeObserver(self, forKeyPath: "status")
|
||||||
|
loadPlayer?.currentVideo?.resourcePlayerItem.removeObserver(self, forKeyPath: "loadedTimeRanges")
|
||||||
|
loadPlayer?.currentVideo?.resourcePlayerItem.removeObserver(self, forKeyPath: "playbackLikelyToKeepUp")
|
||||||
|
loadPlayer?.currentVideo?.isKVO = false
|
||||||
|
//重新配置数据
|
||||||
|
loadPlayer.remakeImproveData {
|
||||||
|
[weak self] in
|
||||||
|
self?.play()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
case "loadedTimeRanges"://当前缓冲进度
|
case "loadedTimeRanges"://当前缓冲进度
|
||||||
cacheLoadTimes()
|
cacheLoadTimes()
|
||||||
@ -455,6 +455,13 @@ class MP_PlayerManager:NSObject{
|
|||||||
//判断当前音乐播放方式
|
//判断当前音乐播放方式
|
||||||
switch playType {
|
switch playType {
|
||||||
case .random://随机,播放随机列表内容
|
case .random://随机,播放随机列表内容
|
||||||
|
//检索当前列表是否为只有一首
|
||||||
|
guard (loadPlayer?.randomVideos?.count ?? 0) != 1 else {
|
||||||
|
player.seek(to: .zero)
|
||||||
|
playState = .Playing
|
||||||
|
player.play()
|
||||||
|
return
|
||||||
|
}
|
||||||
for (index, item) in loadPlayer.randomVideos.enumerated() {
|
for (index, item) in loadPlayer.randomVideos.enumerated() {
|
||||||
if item.videoId == loadPlayer.currentVideo?.song.videoId {
|
if item.videoId == loadPlayer.currentVideo?.song.videoId {
|
||||||
//找到播放音乐的索引
|
//找到播放音乐的索引
|
||||||
@ -472,6 +479,12 @@ class MP_PlayerManager:NSObject{
|
|||||||
loadPlayer.improveData(song.videoId ?? "", isRandom: true)
|
loadPlayer.improveData(song.videoId ?? "", isRandom: true)
|
||||||
}
|
}
|
||||||
default://常规播放或者单曲播放
|
default://常规播放或者单曲播放
|
||||||
|
guard (loadPlayer?.songVideos?.count ?? 0) != 1 else {
|
||||||
|
player.seek(to: .zero)
|
||||||
|
playState = .Playing
|
||||||
|
player.play()
|
||||||
|
return
|
||||||
|
}
|
||||||
for (index, item) in loadPlayer.songVideos.enumerated() {
|
for (index, item) in loadPlayer.songVideos.enumerated() {
|
||||||
if item.videoId == loadPlayer.currentVideo?.song.videoId {
|
if item.videoId == loadPlayer.currentVideo?.song.videoId {
|
||||||
//找到播放音乐的索引
|
//找到播放音乐的索引
|
||||||
@ -497,6 +510,12 @@ class MP_PlayerManager:NSObject{
|
|||||||
var nextIndex:Int = 0
|
var nextIndex:Int = 0
|
||||||
switch playType {
|
switch playType {
|
||||||
case .random:
|
case .random:
|
||||||
|
guard (loadPlayer?.randomVideos?.count ?? 0) != 1 else {
|
||||||
|
player.seek(to: .zero)
|
||||||
|
playState = .Playing
|
||||||
|
player.play()
|
||||||
|
return
|
||||||
|
}
|
||||||
for (index, item) in loadPlayer.randomVideos.enumerated() {
|
for (index, item) in loadPlayer.randomVideos.enumerated() {
|
||||||
if item.videoId == loadPlayer.currentVideo?.song.videoId {
|
if item.videoId == loadPlayer.currentVideo?.song.videoId {
|
||||||
//找到播放音乐的索引
|
//找到播放音乐的索引
|
||||||
@ -514,6 +533,12 @@ class MP_PlayerManager:NSObject{
|
|||||||
loadPlayer.improveData(song.videoId ?? "", isRandom: true)
|
loadPlayer.improveData(song.videoId ?? "", isRandom: true)
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
guard (loadPlayer?.songVideos?.count ?? 0) != 1 else {
|
||||||
|
player.seek(to: .zero)
|
||||||
|
playState = .Playing
|
||||||
|
player.play()
|
||||||
|
return
|
||||||
|
}
|
||||||
for (index, item) in loadPlayer.songVideos.enumerated() {
|
for (index, item) in loadPlayer.songVideos.enumerated() {
|
||||||
if item.videoId == loadPlayer.currentVideo?.song.videoId {
|
if item.videoId == loadPlayer.currentVideo?.song.videoId {
|
||||||
//找到播放音乐的索引
|
//找到播放音乐的索引
|
||||||
@ -632,53 +657,73 @@ class MP_PlayerManager:NSObject{
|
|||||||
return .noActionableNowPlayingItem
|
return .noActionableNowPlayingItem
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//拖拽进度
|
||||||
|
center?.changePlaybackPositionCommand.addTarget(handler: { [weak self] event in
|
||||||
|
guard let self = self else { return .noActionableNowPlayingItem}
|
||||||
|
|
||||||
|
guard let positionEvent = event as? MPChangePlaybackPositionCommandEvent else {
|
||||||
|
return .commandFailed
|
||||||
|
}
|
||||||
|
if loadPlayer.currentVideo != nil {
|
||||||
|
self.player.seek(to: CMTime(seconds: positionEvent.positionTime, preferredTimescale: 1))
|
||||||
|
return .success
|
||||||
|
}else {
|
||||||
|
return .noActionableNowPlayingItem
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
//设置远程中心内容更新
|
//设置远程中心内容更新
|
||||||
func updateNowPlayingInfo() {
|
func updateNowPlayingInfo() {
|
||||||
|
guard loadPlayer?.currentVideo != nil else {return}
|
||||||
//设置info字典信息
|
//设置info字典信息
|
||||||
var info = [String:Any]()
|
currentInfo = [:]
|
||||||
//展示标题
|
//展示标题
|
||||||
info[MPMediaItemPropertyTitle] = loadPlayer.currentVideo?.title ?? ""
|
currentInfo![MPMediaItemPropertyTitle] = loadPlayer?.currentVideo?.title ?? ""
|
||||||
//设置艺术家
|
//设置艺术家
|
||||||
info[MPMediaItemPropertyArtist] = loadPlayer.currentVideo?.song?.shortBylineText ?? ""
|
currentInfo![MPMediaItemPropertyArtist] = loadPlayer?.currentVideo?.song?.shortBylineText ?? ""
|
||||||
//设置专辑
|
//设置专辑
|
||||||
info[MPMediaItemPropertyAlbumTitle] = loadPlayer.currentVideo?.song?.longBylineText
|
currentInfo![MPMediaItemPropertyAlbumTitle] = loadPlayer?.currentVideo?.song?.longBylineText
|
||||||
|
//当前时长
|
||||||
|
currentInfo![MPNowPlayingInfoPropertyElapsedPlaybackTime] = CMTimeGetSeconds(player.currentItem?.currentTime() ?? .zero)
|
||||||
//设置歌曲时长
|
//设置歌曲时长
|
||||||
info[MPMediaItemPropertyPlaybackDuration] = getMusicDuration()
|
currentInfo![MPMediaItemPropertyPlaybackDuration] = CMTimeGetSeconds(player.currentItem?.duration ?? .zero)
|
||||||
|
currentInfo![MPNowPlayingInfoPropertyPlaybackRate] = 1.0
|
||||||
let reviewURL = URL(string: loadPlayer.currentVideo?.song?.reviewUrls?.last ?? "")!
|
let reviewURL = URL(string: loadPlayer.currentVideo?.song?.reviewUrls?.last ?? "")!
|
||||||
KingfisherManager.shared.retrieveImage(with: reviewURL) { result in
|
KingfisherManager.shared.retrieveImage(with: reviewURL) { [weak self]result in
|
||||||
switch result {
|
switch result {
|
||||||
case .success(let imageResult):
|
case .success(let imageResult):
|
||||||
let image = imageResult.image
|
let image = imageResult.image
|
||||||
info[MPMediaItemPropertyArtwork] = MPMediaItemArtwork(boundsSize: image.size, requestHandler: { size in
|
self?.currentInfo?[MPMediaItemPropertyArtwork] = MPMediaItemArtwork(boundsSize: image.size, requestHandler: { size in
|
||||||
return image
|
return image
|
||||||
})
|
})
|
||||||
// 确保更新MPNowPlayingInfoCenter的操作在主线程中
|
// 确保更新MPNowPlayingInfoCenter的操作在主线程中
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
//更新远程中心
|
//更新远程中心
|
||||||
MPNowPlayingInfoCenter.default().nowPlayingInfo = info
|
MPNowPlayingInfoCenter.default().nowPlayingInfo = self?.currentInfo
|
||||||
}
|
}
|
||||||
case .failure(_):
|
case .failure(_):
|
||||||
info[MPMediaItemPropertyArtwork] = MPMediaItemArtwork(boundsSize: placeholderImage.size, requestHandler: { size in
|
self?.currentInfo?[MPMediaItemPropertyArtwork] = MPMediaItemArtwork(boundsSize: placeholderImage.size, requestHandler: { size in
|
||||||
return placeholderImage
|
return placeholderImage
|
||||||
})
|
})
|
||||||
// 确保更新MPNowPlayingInfoCenter的操作在主线程中
|
// 确保更新MPNowPlayingInfoCenter的操作在主线程中
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
//更新远程中心
|
//更新远程中心
|
||||||
MPNowPlayingInfoCenter.default().nowPlayingInfo = info
|
MPNowPlayingInfoCenter.default().nowPlayingInfo = self?.currentInfo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//实时更新当前控制中心的进度条信息
|
//实时更新当前控制中心的进度条信息
|
||||||
private func updateProgress(_ time:TimeInterval) {
|
// private func updateProgress(_ time:TimeInterval) {
|
||||||
if var nowPlayingInfo = MPNowPlayingInfoCenter.default().nowPlayingInfo {
|
// guard var currentInfo = currentInfo else {
|
||||||
nowPlayingInfo[MPNowPlayingInfoPropertyElapsedPlaybackTime] = time
|
// return
|
||||||
DispatchQueue.main.async {
|
// }
|
||||||
//更新远程中心
|
// currentInfo[MPNowPlayingInfoPropertyElapsedPlaybackTime] = setTimesToMinSeconds(time)
|
||||||
MPNowPlayingInfoCenter.default().nowPlayingInfo = nowPlayingInfo
|
// DispatchQueue.main.async {
|
||||||
}
|
// print(currentInfo)
|
||||||
}
|
// //更新远程中心
|
||||||
}
|
// MPNowPlayingInfoCenter.default().nowPlayingInfo = currentInfo
|
||||||
|
// }
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -21,9 +21,14 @@ class MPPositive_BrowseLoadViewModel: NSObject {
|
|||||||
browseModuleLists.append(contentsOf: lists)
|
browseModuleLists.append(contentsOf: lists)
|
||||||
//移除为空的数据
|
//移除为空的数据
|
||||||
browseModuleLists = browseModuleLists.filter{($0.items.count != 0)}
|
browseModuleLists = browseModuleLists.filter{($0.items.count != 0)}
|
||||||
//通知首页刷新UI
|
|
||||||
NotificationCenter.notificationKey.post(notificationName: .positive_browses_reload)
|
|
||||||
if isCompleted == true {
|
if isCompleted == true {
|
||||||
|
//将视频移动到最后
|
||||||
|
if let index = browseModuleLists.firstIndex(where: {$0.items.first?.browseItem.pageType == "MUSIC_VIDEO_TYPE_OMV"}) {
|
||||||
|
let removedElement = browseModuleLists.remove(at: index)
|
||||||
|
browseModuleLists.append(removedElement)
|
||||||
|
}
|
||||||
|
//通知首页刷新UI
|
||||||
|
NotificationCenter.notificationKey.post(notificationName: .positive_browses_reload)
|
||||||
//加载完毕后
|
//加载完毕后
|
||||||
MP_AnalyticsManager.shared.home_b_module_showsucces_actionAction()
|
MP_AnalyticsManager.shared.home_b_module_showsucces_actionAction()
|
||||||
}
|
}
|
||||||
|
|||||||
@ -146,30 +146,8 @@ class MPPositive_PlayerLoadViewModel: NSObject {
|
|||||||
}
|
}
|
||||||
///重新获取指定歌曲资源
|
///重新获取指定歌曲资源
|
||||||
func remakeImproveData(_ completion:@escaping (() -> Void)) {
|
func remakeImproveData(_ completion:@escaping (() -> Void)) {
|
||||||
//当前歌曲不能播放,需要重新配置资源
|
currentVideo.configure()
|
||||||
improveDataforResouceAndCover(currentVideo.song) {[weak self] resourceUrls, coverUrls in
|
completion()
|
||||||
guard let self = self else {return}
|
|
||||||
if let resourceUrls = resourceUrls {
|
|
||||||
currentVideo.song.resourceUrls = resourceUrls.0
|
|
||||||
currentVideo.song.itags = resourceUrls.1
|
|
||||||
currentVideo.song.mimeTypes = resourceUrls.2
|
|
||||||
}
|
|
||||||
//成功更新资源,将重新补完的歌曲,放进listViewVideos中
|
|
||||||
listViewVideos.forEach({ item in
|
|
||||||
if item.song.videoId == self.currentVideo.song.videoId {
|
|
||||||
item.song.resourceUrls = self.currentVideo.song.resourceUrls
|
|
||||||
item.song.itags = self.currentVideo.song.itags
|
|
||||||
item.song.mimeTypes = self.currentVideo.song.mimeTypes
|
|
||||||
}
|
|
||||||
})
|
|
||||||
// currentVideo.resourceAsset = .init(url: .init(string: currentVideo.song.resourceUrls!.first!)!)
|
|
||||||
// currentVideo.resourcePlayerItem = .init(asset: currentVideo.resourceAsset!)
|
|
||||||
// currentVideo.resourcePlayerItem = .init(url: .init(string: (currentVideo.song.resourceUrls?.first ?? ""))!, bitrate: Int64(currentVideo.song.bitrates?.first ?? 0), title: currentVideo.title, videoId: currentVideo.song.videoId)
|
|
||||||
currentVideo.configure()
|
|
||||||
//当值变化时通知播放器页面,更新UI
|
|
||||||
NotificationCenter.notificationKey.post(notificationName: .positive_player_reload)
|
|
||||||
completion()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
///移除选中的song,并更新listViewVideos,移除相同index的值
|
///移除选中的song,并更新listViewVideos,移除相同index的值
|
||||||
|
|||||||
@ -91,7 +91,7 @@ class MPPositive_BaseViewController: MP_BaseViewController {
|
|||||||
make.width.equalTo(211*width)
|
make.width.equalTo(211*width)
|
||||||
make.height.equalTo(172*width)
|
make.height.equalTo(172*width)
|
||||||
}
|
}
|
||||||
let label = createLabel("Failure to obtain data", font: .systemFont(ofSize: 13*width, weight: .regular), textColor: .white, textAlignment: .center)
|
let label = createLabel("Weak connection. Please check your network", font: .systemFont(ofSize: 13*width, weight: .regular), textColor: .white, textAlignment: .center)
|
||||||
errorView.addSubview(label)
|
errorView.addSubview(label)
|
||||||
label.snp.makeConstraints { make in
|
label.snp.makeConstraints { make in
|
||||||
make.centerX.equalToSuperview()
|
make.centerX.equalToSuperview()
|
||||||
@ -134,7 +134,7 @@ class MPPositive_BaseViewController: MP_BaseViewController {
|
|||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
[weak self] in
|
[weak self] in
|
||||||
guard let self = self else {return}
|
guard let self = self else {return}
|
||||||
MP_HUD.text("Failure to obtain data", delay: 1.0){ [weak self] in
|
MP_HUD.text("Weak connection.", delay: 1.0){ [weak self] in
|
||||||
//执行报错回调闭包
|
//执行报错回调闭包
|
||||||
if self?.errorBlock != nil {
|
if self?.errorBlock != nil {
|
||||||
self?.errorBlock!()
|
self?.errorBlock!()
|
||||||
|
|||||||
@ -9,8 +9,6 @@ import UIKit
|
|||||||
import Kingfisher
|
import Kingfisher
|
||||||
///更多操作
|
///更多操作
|
||||||
class MPPositive_MoreSongOperationsViewController: UIViewController {
|
class MPPositive_MoreSongOperationsViewController: UIViewController {
|
||||||
//下载进度条View
|
|
||||||
private var loadView = CircularProgressView()
|
|
||||||
//小角标图片
|
//小角标图片
|
||||||
private lazy var indictorImageView:UIImageView = .init(image: .init(named: "Player_Indictor'logo"))
|
private lazy var indictorImageView:UIImageView = .init(image: .init(named: "Player_Indictor'logo"))
|
||||||
//展示ICON
|
//展示ICON
|
||||||
@ -267,6 +265,7 @@ class MPPositive_MoreSongOperationsViewController: UIViewController {
|
|||||||
}
|
}
|
||||||
//是否收藏
|
//是否收藏
|
||||||
@objc private func collectionClick(_ sender:UIButton) {
|
@objc private func collectionClick(_ sender:UIButton) {
|
||||||
|
getUserNotificationCenter()
|
||||||
if self.collectionBtn.isSelected == true{
|
if self.collectionBtn.isSelected == true{
|
||||||
self.collectionBtn.isSelected = false
|
self.collectionBtn.isSelected = false
|
||||||
MPPositive_CollectionSongModel.fetch(.init(format: "videoId == %@", song.videoId)).forEach { item in
|
MPPositive_CollectionSongModel.fetch(.init(format: "videoId == %@", song.videoId)).forEach { item in
|
||||||
@ -315,6 +314,7 @@ extension MPPositive_MoreSongOperationsViewController:UITableViewDataSource, UIT
|
|||||||
}
|
}
|
||||||
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
||||||
if indexPath.row == 0 {
|
if indexPath.row == 0 {
|
||||||
|
getUserNotificationCenter()
|
||||||
if isLoaded {
|
if isLoaded {
|
||||||
//移除下载
|
//移除下载
|
||||||
MPPositive_DownloadItemModel.fetch(.init(format: "videoId == %@", song.videoId)).forEach { item in
|
MPPositive_DownloadItemModel.fetch(.init(format: "videoId == %@", song.videoId)).forEach { item in
|
||||||
|
|||||||
@ -90,21 +90,11 @@ extension MPPositive_TabBarController {
|
|||||||
@objc private func pupPlayerAction() {
|
@objc private func pupPlayerAction() {
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
[weak self] in
|
[weak self] in
|
||||||
//检索播放器中是否存在load模型
|
|
||||||
// if MP_PlayerManager.shared.loadPlayer != nil{
|
|
||||||
// let playerVC = MPPositive_PlayerViewController()
|
|
||||||
// playerVC.modalPresentationStyle = .fullScreen
|
|
||||||
// playerVC.recommendBlock = {
|
|
||||||
// let recommendVC = MPPositive_RecommendViewController(MP_PlayerManager.shared.loadPlayer.currentVideo.song.relatedID)
|
|
||||||
// self?.viewControllers![self?.selectedIndex ?? 0].children[0].navigationController?.pushViewController(recommendVC, animated: true)
|
|
||||||
// }
|
|
||||||
// self?.present(playerVC, animated: true)
|
|
||||||
// }
|
|
||||||
let playerVC = MPPositive_PlayerViewController()
|
let playerVC = MPPositive_PlayerViewController()
|
||||||
playerVC.modalPresentationStyle = .fullScreen
|
playerVC.modalPresentationStyle = .fullScreen
|
||||||
playerVC.recommendBlock = {
|
playerVC.recommendBlock = {
|
||||||
let recommendVC = MPPositive_RecommendViewController(MP_PlayerManager.shared.loadPlayer.currentVideo.song.relatedID)
|
let recommendVC = MPPositive_RecommendViewController(MP_PlayerManager.shared.loadPlayer.currentVideo.song.relatedID)
|
||||||
self?.viewControllers![self?.selectedIndex ?? 0].children[0].navigationController?.pushViewController(recommendVC, animated: true)
|
self?.viewControllers![self?.selectedIndex ?? 0].children[0].navigationController?.pushViewController(recommendVC, animated: false)
|
||||||
}
|
}
|
||||||
self?.present(playerVC, animated: true)
|
self?.present(playerVC, animated: true)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -93,10 +93,14 @@ extension MPPositive_LoveSongsViewController: UITableViewDataSource, UITableView
|
|||||||
MPPositive_Debouncer.shared.call {
|
MPPositive_Debouncer.shared.call {
|
||||||
[weak self] in
|
[weak self] in
|
||||||
guard let self = self else {return}
|
guard let self = self else {return}
|
||||||
//弹出播放器
|
guard MP_NetWorkManager.shared.netWorkStatu == .reachable else {
|
||||||
NotificationCenter.notificationKey.post(notificationName: .pup_player_vc)
|
MP_HUD.text("Weak connection.", delay: 2.0, completion: nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
//优先清除数据
|
//优先清除数据
|
||||||
MP_PlayerManager.shared.loadPlayer = nil
|
MP_PlayerManager.shared.loadPlayer = nil
|
||||||
|
//弹出播放器
|
||||||
|
NotificationCenter.notificationKey.post(notificationName: .pup_player_vc)
|
||||||
//将当前收藏音乐放入列表中
|
//将当前收藏音乐放入列表中
|
||||||
var array:[MPPositive_SongItemModel] = []
|
var array:[MPPositive_SongItemModel] = []
|
||||||
for (index,song) in MPPositive_LoadCoreModel.shared.songViewModels.enumerated() {
|
for (index,song) in MPPositive_LoadCoreModel.shared.songViewModels.enumerated() {
|
||||||
@ -114,7 +118,6 @@ extension MPPositive_LoveSongsViewController: UITableViewDataSource, UITableView
|
|||||||
let lodaViewModel = MPPositive_PlayerLoadViewModel(array, currentVideoId: MPPositive_LoadCoreModel.shared.songViewModels[indexPath.row].collectionSong.videoId ?? "")
|
let lodaViewModel = MPPositive_PlayerLoadViewModel(array, currentVideoId: MPPositive_LoadCoreModel.shared.songViewModels[indexPath.row].collectionSong.videoId ?? "")
|
||||||
lodaViewModel.improveData(MPPositive_LoadCoreModel.shared.songViewModels[indexPath.row].collectionSong.videoId ?? "")
|
lodaViewModel.improveData(MPPositive_LoadCoreModel.shared.songViewModels[indexPath.row].collectionSong.videoId ?? "")
|
||||||
MP_PlayerManager.shared.loadPlayer = lodaViewModel
|
MP_PlayerManager.shared.loadPlayer = lodaViewModel
|
||||||
// NotificationCenter.notificationKey.post(notificationName: .pup_player_vc)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
func presentationController(forPresented presented: UIViewController, presenting: UIViewController?, source: UIViewController) -> UIPresentationController? {
|
func presentationController(forPresented presented: UIViewController, presenting: UIViewController?, source: UIViewController) -> UIPresentationController? {
|
||||||
|
|||||||
@ -99,10 +99,10 @@ extension MPPositive_OfflineSongsViewController: UITableViewDataSource, UITableV
|
|||||||
MPPositive_Debouncer.shared.call {
|
MPPositive_Debouncer.shared.call {
|
||||||
[weak self] in
|
[weak self] in
|
||||||
guard let self = self else {return}
|
guard let self = self else {return}
|
||||||
//弹出播放器
|
|
||||||
NotificationCenter.notificationKey.post(notificationName: .pup_player_vc)
|
|
||||||
//优先清除数据
|
//优先清除数据
|
||||||
MP_PlayerManager.shared.loadPlayer = nil
|
MP_PlayerManager.shared.loadPlayer = nil
|
||||||
|
//弹出播放器
|
||||||
|
NotificationCenter.notificationKey.post(notificationName: .pup_player_vc)
|
||||||
//将当前下载音乐放入列表中
|
//将当前下载音乐放入列表中
|
||||||
var array:[MPPositive_SongItemModel] = []
|
var array:[MPPositive_SongItemModel] = []
|
||||||
for (index, song) in MPPositive_LoadCoreModel.shared.loadViewModels.enumerated() {
|
for (index, song) in MPPositive_LoadCoreModel.shared.loadViewModels.enumerated() {
|
||||||
|
|||||||
@ -215,11 +215,15 @@ extension MPPositive_ArtistShowViewController: JXPagingViewDelegate{
|
|||||||
MPPositive_Debouncer.shared.call {
|
MPPositive_Debouncer.shared.call {
|
||||||
[weak self] in
|
[weak self] in
|
||||||
guard let self = self else {return}
|
guard let self = self else {return}
|
||||||
|
guard MP_NetWorkManager.shared.netWorkStatu == .reachable else {
|
||||||
|
MP_HUD.text("Weak connection.", delay: 2.0, completion: nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
//优先清除数据
|
||||||
|
MP_PlayerManager.shared.loadPlayer = nil
|
||||||
//单曲/视频跳转
|
//单曲/视频跳转
|
||||||
//弹出播放器
|
//弹出播放器
|
||||||
NotificationCenter.notificationKey.post(notificationName: .pup_player_vc)
|
NotificationCenter.notificationKey.post(notificationName: .pup_player_vc)
|
||||||
//优先清除数据
|
|
||||||
MP_PlayerManager.shared.loadPlayer = nil
|
|
||||||
//触发next请求,优先获取列表全部单曲基础数据(不完善)
|
//触发next请求,优先获取列表全部单曲基础数据(不完善)
|
||||||
MP_NetWorkManager.shared.requestNextList(item.browseItem.playListId ?? "", videoId: item.browseItem.videoId ?? ""){ [weak self] listSongs in
|
MP_NetWorkManager.shared.requestNextList(item.browseItem.playListId ?? "", videoId: item.browseItem.videoId ?? ""){ [weak self] listSongs in
|
||||||
guard let self = self else {return}
|
guard let self = self else {return}
|
||||||
|
|||||||
@ -158,10 +158,14 @@ extension MPPositive_HomeViewController: UITableViewDataSource, UITableViewDeleg
|
|||||||
MPPositive_Debouncer.shared.call {
|
MPPositive_Debouncer.shared.call {
|
||||||
[weak self] in
|
[weak self] in
|
||||||
guard let self = self else {return}
|
guard let self = self else {return}
|
||||||
//弹出播放器
|
guard MP_NetWorkManager.shared.netWorkStatu == .reachable else {
|
||||||
NotificationCenter.notificationKey.post(notificationName: .pup_player_vc)
|
MP_HUD.text("Weak connection.", delay: 2.0, completion: nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
//优先清除数据
|
//优先清除数据
|
||||||
MP_PlayerManager.shared.loadPlayer = nil
|
MP_PlayerManager.shared.loadPlayer = nil
|
||||||
|
//弹出播放器
|
||||||
|
NotificationCenter.notificationKey.post(notificationName: .pup_player_vc)
|
||||||
//触发next请求,优先获取列表全部单曲基础数据(不完善)
|
//触发next请求,优先获取列表全部单曲基础数据(不完善)
|
||||||
MP_NetWorkManager.shared.requestNextList(item.browseItem.playListId ?? "", videoId: item.browseItem.videoId ?? ""){ [weak self] listSongs in
|
MP_NetWorkManager.shared.requestNextList(item.browseItem.playListId ?? "", videoId: item.browseItem.videoId ?? ""){ [weak self] listSongs in
|
||||||
guard let self = self else {return}
|
guard let self = self else {return}
|
||||||
@ -169,7 +173,6 @@ extension MPPositive_HomeViewController: UITableViewDataSource, UITableViewDeleg
|
|||||||
let lodaViewModel = MPPositive_PlayerLoadViewModel(listSongs, currentVideoId: item.browseItem.videoId ?? "")
|
let lodaViewModel = MPPositive_PlayerLoadViewModel(listSongs, currentVideoId: item.browseItem.videoId ?? "")
|
||||||
lodaViewModel.improveData(item.browseItem.videoId ?? "")
|
lodaViewModel.improveData(item.browseItem.videoId ?? "")
|
||||||
MP_PlayerManager.shared.loadPlayer = lodaViewModel
|
MP_PlayerManager.shared.loadPlayer = lodaViewModel
|
||||||
// NotificationCenter.notificationKey.post(notificationName: .pup_player_vc)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case .list:
|
case .list:
|
||||||
|
|||||||
@ -248,15 +248,19 @@ class MPPositive_ListShowViewController: MPPositive_BaseViewController, UIViewCo
|
|||||||
}
|
}
|
||||||
|
|
||||||
//MARK: - 点击事件
|
//MARK: - 点击事件
|
||||||
//播放/暂停列表
|
//播放列表
|
||||||
@objc private func playListActionClick(_ sender:UITapGestureRecognizer) {
|
@objc private func playListActionClick(_ sender:UITapGestureRecognizer) {
|
||||||
MPPositive_Debouncer.shared.call {
|
MPPositive_Debouncer.shared.call {
|
||||||
[weak self] in
|
[weak self] in
|
||||||
guard let self = self, let item = listOrAlbum.items.randomElement() else {return}
|
guard let self = self, let item = listOrAlbum.items.randomElement() else {return}
|
||||||
//弹出播放器
|
guard MP_NetWorkManager.shared.netWorkStatu == .reachable else {
|
||||||
NotificationCenter.notificationKey.post(notificationName: .pup_player_vc)
|
MP_HUD.text("Weak connection.", delay: 2.0, completion: nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
//优先清除数据
|
//优先清除数据
|
||||||
MP_PlayerManager.shared.loadPlayer = nil
|
MP_PlayerManager.shared.loadPlayer = nil
|
||||||
|
//弹出播放器
|
||||||
|
NotificationCenter.notificationKey.post(notificationName: .pup_player_vc)
|
||||||
//触发next请求,优先获取列表全部单曲基础数据(不完善)
|
//触发next请求,优先获取列表全部单曲基础数据(不完善)
|
||||||
MP_NetWorkManager.shared.requestNextList(item.browseItem.playListId ?? "", videoId: item.browseItem.videoId ?? ""){ [weak self] listSongs in
|
MP_NetWorkManager.shared.requestNextList(item.browseItem.playListId ?? "", videoId: item.browseItem.videoId ?? ""){ [weak self] listSongs in
|
||||||
guard let self = self else {return}
|
guard let self = self else {return}
|
||||||
@ -264,13 +268,13 @@ class MPPositive_ListShowViewController: MPPositive_BaseViewController, UIViewCo
|
|||||||
let lodaViewModel = MPPositive_PlayerLoadViewModel(listSongs, currentVideoId: item.browseItem.videoId ?? "")
|
let lodaViewModel = MPPositive_PlayerLoadViewModel(listSongs, currentVideoId: item.browseItem.videoId ?? "")
|
||||||
lodaViewModel.improveData(item.browseItem.videoId ?? "")
|
lodaViewModel.improveData(item.browseItem.videoId ?? "")
|
||||||
MP_PlayerManager.shared.loadPlayer = lodaViewModel
|
MP_PlayerManager.shared.loadPlayer = lodaViewModel
|
||||||
//弹出播放器
|
|
||||||
// NotificationCenter.notificationKey.post(notificationName: .pup_player_vc)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//切换当前列表收藏状态
|
//切换当前列表收藏状态
|
||||||
@objc private func collectionSwitchClick(_ sender:UIButton) {
|
@objc private func collectionSwitchClick(_ sender:UIButton) {
|
||||||
|
getUserNotificationCenter()
|
||||||
if self.collectionListBtn.isSelected == true{
|
if self.collectionListBtn.isSelected == true{
|
||||||
self.collectionListBtn.isSelected = false
|
self.collectionListBtn.isSelected = false
|
||||||
|
|
||||||
@ -322,6 +326,10 @@ extension MPPositive_ListShowViewController: UITableViewDataSource, UITableViewD
|
|||||||
MPPositive_Debouncer.shared.call {
|
MPPositive_Debouncer.shared.call {
|
||||||
[weak self] in
|
[weak self] in
|
||||||
guard let self = self else {return}
|
guard let self = self else {return}
|
||||||
|
guard MP_NetWorkManager.shared.netWorkStatu == .reachable else {
|
||||||
|
MP_HUD.text("Weak connection.", delay: 2.0, completion: nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
//弹出播放器
|
//弹出播放器
|
||||||
NotificationCenter.notificationKey.post(notificationName: .pup_player_vc)
|
NotificationCenter.notificationKey.post(notificationName: .pup_player_vc)
|
||||||
//触发next请求,优先获取列表全部单曲基础数据(不完善)
|
//触发next请求,优先获取列表全部单曲基础数据(不完善)
|
||||||
@ -331,8 +339,6 @@ extension MPPositive_ListShowViewController: UITableViewDataSource, UITableViewD
|
|||||||
let lodaViewModel = MPPositive_PlayerLoadViewModel(listSongs, currentVideoId: listOrAlbum.items[indexPath.row].browseItem.videoId ?? "")
|
let lodaViewModel = MPPositive_PlayerLoadViewModel(listSongs, currentVideoId: listOrAlbum.items[indexPath.row].browseItem.videoId ?? "")
|
||||||
lodaViewModel.improveData(listOrAlbum.items[indexPath.row].browseItem.videoId ?? "")
|
lodaViewModel.improveData(listOrAlbum.items[indexPath.row].browseItem.videoId ?? "")
|
||||||
MP_PlayerManager.shared.loadPlayer = lodaViewModel
|
MP_PlayerManager.shared.loadPlayer = lodaViewModel
|
||||||
//发布弹出音乐播放器的通知
|
|
||||||
// NotificationCenter.notificationKey.post(notificationName: .pup_player_vc)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -62,7 +62,7 @@ class MPPositive_MoreContentViewController: MPPositive_BaseViewController {
|
|||||||
var browseModuleList:MPPositive_BrowseModuleListViewModel!
|
var browseModuleList:MPPositive_BrowseModuleListViewModel!
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
setTitle("Report")
|
setTitle("More")
|
||||||
setPopBtn()
|
setPopBtn()
|
||||||
confirgue()
|
confirgue()
|
||||||
}
|
}
|
||||||
@ -113,10 +113,14 @@ extension MPPositive_MoreContentViewController: UICollectionViewDataSource, UICo
|
|||||||
MPPositive_Debouncer.shared.call {
|
MPPositive_Debouncer.shared.call {
|
||||||
[weak self] in
|
[weak self] in
|
||||||
guard let self = self else {return}
|
guard let self = self else {return}
|
||||||
//弹出播放器
|
guard MP_NetWorkManager.shared.netWorkStatu == .reachable else {
|
||||||
NotificationCenter.notificationKey.post(notificationName: .pup_player_vc)
|
MP_HUD.text("Weak connection.", delay: 2.0, completion: nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
//优先清除数据
|
//优先清除数据
|
||||||
MP_PlayerManager.shared.loadPlayer = nil
|
MP_PlayerManager.shared.loadPlayer = nil
|
||||||
|
//弹出播放器
|
||||||
|
NotificationCenter.notificationKey.post(notificationName: .pup_player_vc)
|
||||||
//触发next请求,优先获取列表全部单曲基础数据(不完善)
|
//触发next请求,优先获取列表全部单曲基础数据(不完善)
|
||||||
MP_NetWorkManager.shared.requestNextList(browseModuleList.items[indexPath.row].browseItem.playListId ?? "", videoId: browseModuleList.items[indexPath.row].browseItem.videoId ?? ""){ [weak self] listSongs in
|
MP_NetWorkManager.shared.requestNextList(browseModuleList.items[indexPath.row].browseItem.playListId ?? "", videoId: browseModuleList.items[indexPath.row].browseItem.videoId ?? ""){ [weak self] listSongs in
|
||||||
guard let self = self else {return}
|
guard let self = self else {return}
|
||||||
@ -124,7 +128,6 @@ extension MPPositive_MoreContentViewController: UICollectionViewDataSource, UICo
|
|||||||
let lodaViewModel = MPPositive_PlayerLoadViewModel(listSongs, currentVideoId: browseModuleList.items[indexPath.row].browseItem.videoId ?? "")
|
let lodaViewModel = MPPositive_PlayerLoadViewModel(listSongs, currentVideoId: browseModuleList.items[indexPath.row].browseItem.videoId ?? "")
|
||||||
lodaViewModel.improveData(browseModuleList.items[indexPath.row].browseItem.videoId ?? "")
|
lodaViewModel.improveData(browseModuleList.items[indexPath.row].browseItem.videoId ?? "")
|
||||||
MP_PlayerManager.shared.loadPlayer = lodaViewModel
|
MP_PlayerManager.shared.loadPlayer = lodaViewModel
|
||||||
// NotificationCenter.notificationKey.post(notificationName: .pup_player_vc)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|||||||
@ -123,6 +123,7 @@ class MPPositive_PlayerViewController: MPPositive_BaseViewController, UIViewCont
|
|||||||
//歌词View
|
//歌词View
|
||||||
private lazy var lyricsView:MPPositive_PlayerLyricView = .init(frame: .init(x: 0, y: 0, width: screen_Width, height: 480*width))
|
private lazy var lyricsView:MPPositive_PlayerLyricView = .init(frame: .init(x: 0, y: 0, width: screen_Width, height: 480*width))
|
||||||
var recommendBlock:(() -> Void)?
|
var recommendBlock:(() -> Void)?
|
||||||
|
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
//隐藏导航栏label
|
//隐藏导航栏label
|
||||||
@ -420,6 +421,10 @@ class MPPositive_PlayerViewController: MPPositive_BaseViewController, UIViewCont
|
|||||||
}
|
}
|
||||||
//切换页面显示内容(单曲封面|歌词)按钮组
|
//切换页面显示内容(单曲封面|歌词)按钮组
|
||||||
@objc private func switchActionClick(_ sender:UIButton) {
|
@objc private func switchActionClick(_ sender:UIButton) {
|
||||||
|
guard MP_NetWorkManager.shared.netWorkStatu == .reachable else {
|
||||||
|
MP_HUD.text("Weak connection.", delay: 2.0, completion: nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
topShowType = .init(rawValue: sender.tag)!
|
topShowType = .init(rawValue: sender.tag)!
|
||||||
}
|
}
|
||||||
//切换动画
|
//切换动画
|
||||||
@ -467,17 +472,23 @@ class MPPositive_PlayerViewController: MPPositive_BaseViewController, UIViewCont
|
|||||||
}
|
}
|
||||||
//弹出关联内容
|
//弹出关联内容
|
||||||
@objc private func relatedContentClick(_ sender:UIButton) {
|
@objc private func relatedContentClick(_ sender:UIButton) {
|
||||||
//先dismiss
|
guard MP_NetWorkManager.shared.netWorkStatu == .reachable else {
|
||||||
dismiss(animated: true) {[weak self] in
|
MP_HUD.text("Weak connection.", delay: 2.0, completion: nil)
|
||||||
guard let self = self else {return}
|
return
|
||||||
if recommendBlock != nil {
|
|
||||||
recommendBlock!()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
//先dismiss
|
||||||
|
if recommendBlock != nil {
|
||||||
|
recommendBlock!()
|
||||||
|
}
|
||||||
|
dismiss(animated: true)
|
||||||
}
|
}
|
||||||
|
|
||||||
//播放/暂停/继续
|
//播放/暂停/继续
|
||||||
@objc private func playClick(_ sender:UIButton) {
|
@objc private func playClick(_ sender:UIButton) {
|
||||||
|
guard MP_NetWorkManager.shared.netWorkStatu == .reachable else {
|
||||||
|
MP_HUD.text("Weak connection.", delay: 2.0, completion: nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
guard MP_PlayerManager.shared.loadPlayer != nil else {
|
guard MP_PlayerManager.shared.loadPlayer != nil else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -504,7 +515,12 @@ class MPPositive_PlayerViewController: MPPositive_BaseViewController, UIViewCont
|
|||||||
}
|
}
|
||||||
//展示列表
|
//展示列表
|
||||||
@objc private func listClick(_ sender:UIButton) {
|
@objc private func listClick(_ sender:UIButton) {
|
||||||
|
guard MP_NetWorkManager.shared.netWorkStatu == .reachable else {
|
||||||
|
MP_HUD.text("Weak connection.", delay: 2.0, completion: nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
if MP_PlayerManager.shared.loadPlayer != nil {
|
if MP_PlayerManager.shared.loadPlayer != nil {
|
||||||
|
|
||||||
MPPositive_ModalType = .PlayerList
|
MPPositive_ModalType = .PlayerList
|
||||||
let listVC = MPPositive_PlayerListShowViewController()
|
let listVC = MPPositive_PlayerListShowViewController()
|
||||||
listVC.transitioningDelegate = self
|
listVC.transitioningDelegate = self
|
||||||
@ -517,6 +533,10 @@ class MPPositive_PlayerViewController: MPPositive_BaseViewController, UIViewCont
|
|||||||
}
|
}
|
||||||
//切换播放器状态(按顺序/随机/单曲)
|
//切换播放器状态(按顺序/随机/单曲)
|
||||||
@objc private func typeClick(_ sender:UIButton) {
|
@objc private func typeClick(_ sender:UIButton) {
|
||||||
|
guard MP_NetWorkManager.shared.netWorkStatu == .reachable else {
|
||||||
|
MP_HUD.text("Weak connection.", delay: 2.0, completion: nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
MPPositive_Debouncer.shared.call {
|
MPPositive_Debouncer.shared.call {
|
||||||
[weak self] in
|
[weak self] in
|
||||||
guard let self = self else {return}
|
guard let self = self else {return}
|
||||||
@ -531,22 +551,34 @@ class MPPositive_PlayerViewController: MPPositive_BaseViewController, UIViewCont
|
|||||||
}
|
}
|
||||||
//下一首
|
//下一首
|
||||||
@objc private func nextClick(_ sender:UIButton) {
|
@objc private func nextClick(_ sender:UIButton) {
|
||||||
|
guard MP_NetWorkManager.shared.netWorkStatu == .reachable else {
|
||||||
|
MP_HUD.text("Weak connection.", delay: 2.0, completion: nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
guard MP_PlayerManager.shared.loadPlayer?.currentVideo != nil else {
|
||||||
|
return
|
||||||
|
}
|
||||||
MPPositive_Debouncer.shared.call {
|
MPPositive_Debouncer.shared.call {
|
||||||
[weak self] in
|
[weak self] in
|
||||||
guard let self = self else {return}
|
guard let self = self else {return}
|
||||||
coverView.sliderView.value = 0
|
coverView.sliderView.value = 0
|
||||||
playBtn.isUserInteractionEnabled = false
|
|
||||||
MP_PlayerManager.shared.nextEvent()
|
MP_PlayerManager.shared.nextEvent()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
//上一首
|
//上一首
|
||||||
@objc private func previousClick(_ sender:UIButton) {
|
@objc private func previousClick(_ sender:UIButton) {
|
||||||
|
guard MP_NetWorkManager.shared.netWorkStatu == .reachable else {
|
||||||
|
MP_HUD.text("Weak connection.", delay: 2.0, completion: nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
guard MP_PlayerManager.shared.loadPlayer?.currentVideo != nil else {
|
||||||
|
return
|
||||||
|
}
|
||||||
MPPositive_Debouncer.shared.call {
|
MPPositive_Debouncer.shared.call {
|
||||||
[weak self] in
|
[weak self] in
|
||||||
guard let self = self else {return}
|
guard let self = self else {return}
|
||||||
coverView.sliderView.value = 0
|
coverView.sliderView.value = 0
|
||||||
playBtn.isUserInteractionEnabled = false
|
|
||||||
MP_PlayerManager.shared.previousEvent()
|
MP_PlayerManager.shared.previousEvent()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -229,6 +229,9 @@ extension MPPositive_RecommendViewController: JXSegmentedListContainerViewDataSo
|
|||||||
let listVC = MPPositive_ListShowViewController(item.browseItem.browseId ?? "", params: "", title: item.title ?? "", subtitle: item.subtitle ?? "")
|
let listVC = MPPositive_ListShowViewController(item.browseItem.browseId ?? "", params: "", title: item.title ?? "", subtitle: item.subtitle ?? "")
|
||||||
navigationController?.pushViewController(listVC, animated: true)
|
navigationController?.pushViewController(listVC, animated: true)
|
||||||
case .single:
|
case .single:
|
||||||
|
//优先清除数据
|
||||||
|
MP_PlayerManager.shared.loadPlayer = nil
|
||||||
|
NotificationCenter.notificationKey.post(notificationName: .pup_player_vc)
|
||||||
//单曲/视频跳转
|
//单曲/视频跳转
|
||||||
//触发next请求,优先获取列表全部单曲基础数据(不完善)
|
//触发next请求,优先获取列表全部单曲基础数据(不完善)
|
||||||
MP_NetWorkManager.shared.requestNextList(item.browseItem.playListId ?? "", videoId: item.browseItem.videoId ?? ""){ [weak self] listSongs in
|
MP_NetWorkManager.shared.requestNextList(item.browseItem.playListId ?? "", videoId: item.browseItem.videoId ?? ""){ [weak self] listSongs in
|
||||||
|
|||||||
@ -113,11 +113,15 @@ class MPPositive_SearchResultShowViewController: MPPositive_BaseViewController,
|
|||||||
MPPositive_Debouncer.shared.call {
|
MPPositive_Debouncer.shared.call {
|
||||||
[weak self] in
|
[weak self] in
|
||||||
guard let self = self else {return}
|
guard let self = self else {return}
|
||||||
|
guard MP_NetWorkManager.shared.netWorkStatu == .reachable else {
|
||||||
|
MP_HUD.text("Weak connection.", delay: 2.0, completion: nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
//优先清除数据
|
||||||
|
MP_PlayerManager.shared.loadPlayer = nil
|
||||||
//单曲/视频跳转
|
//单曲/视频跳转
|
||||||
//弹出播放器
|
//弹出播放器
|
||||||
NotificationCenter.notificationKey.post(notificationName: .pup_player_vc)
|
NotificationCenter.notificationKey.post(notificationName: .pup_player_vc)
|
||||||
//优先清除数据
|
|
||||||
MP_PlayerManager.shared.loadPlayer = nil
|
|
||||||
//触发next请求,优先获取列表全部单曲基础数据(不完善)
|
//触发next请求,优先获取列表全部单曲基础数据(不完善)
|
||||||
MP_NetWorkManager.shared.requestNextList(item.item.playListId ?? "", videoId: item.item.videoId ?? ""){ [weak self] listSongs in
|
MP_NetWorkManager.shared.requestNextList(item.item.playListId ?? "", videoId: item.item.videoId ?? ""){ [weak self] listSongs in
|
||||||
guard let self = self else {return}
|
guard let self = self else {return}
|
||||||
|
|||||||
@ -92,6 +92,7 @@ class MPPositive_ArtistShowHeaderView: UIView {
|
|||||||
}
|
}
|
||||||
//收藏这位艺术家
|
//收藏这位艺术家
|
||||||
@objc private func collectionClick(_ sender:UIButton) {
|
@objc private func collectionClick(_ sender:UIButton) {
|
||||||
|
getUserNotificationCenter()
|
||||||
if self.collectionBtn.isSelected == true{
|
if self.collectionBtn.isSelected == true{
|
||||||
self.collectionBtn.isSelected = false
|
self.collectionBtn.isSelected = false
|
||||||
|
|
||||||
|
|||||||
@ -96,6 +96,10 @@ class MPPositive_ArtistShowSongTableViewCell: UITableViewCell {
|
|||||||
var moreBlock:(() -> Void)?
|
var moreBlock:(() -> Void)?
|
||||||
//点击更多
|
//点击更多
|
||||||
@objc private func moreActionClick(_ sender:UIButton) {
|
@objc private func moreActionClick(_ sender:UIButton) {
|
||||||
|
guard MP_NetWorkManager.shared.netWorkStatu == .reachable else {
|
||||||
|
MP_HUD.text("Weak connection.", delay: 2.0, completion: nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
guard moreBlock != nil else {
|
guard moreBlock != nil else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@ -101,6 +101,10 @@ class MPPositive_MusicItemShowTableViewCell: UITableViewCell {
|
|||||||
}
|
}
|
||||||
//点击更多
|
//点击更多
|
||||||
@objc private func moreActionClick(_ sender:UIButton) {
|
@objc private func moreActionClick(_ sender:UIButton) {
|
||||||
|
guard MP_NetWorkManager.shared.netWorkStatu == .reachable else {
|
||||||
|
MP_HUD.text("Weak connection.", delay: 2.0, completion: nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
guard moreBlock != nil else {
|
guard moreBlock != nil else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@ -81,11 +81,21 @@ class MPPositive_PlayerCoverView: UIView, PKDownloadButtonDelegate {
|
|||||||
maskView.backgroundColor = .init(hex: "#000000", alpha: 0.7)
|
maskView.backgroundColor = .init(hex: "#000000", alpha: 0.7)
|
||||||
maskView.layer.masksToBounds = true
|
maskView.layer.masksToBounds = true
|
||||||
maskView.layer.cornerRadius = 16*width
|
maskView.layer.cornerRadius = 16*width
|
||||||
|
//放置一个icon
|
||||||
|
let iconImageView:UIImageView = .init(image: .init(named: "NoNetReache'log"))
|
||||||
|
maskView.addSubview(iconImageView)
|
||||||
|
iconImageView.snp.makeConstraints { make in
|
||||||
|
make.centerX.equalToSuperview()
|
||||||
|
make.centerY.equalToSuperview().multipliedBy(0.8)
|
||||||
|
make.width.equalTo(52*width)
|
||||||
|
make.height.equalTo(42*width)
|
||||||
|
}
|
||||||
//放置一个label
|
//放置一个label
|
||||||
let noticeLabel:UILabel = createLabel("The network connection is disconnected and the player will stop loading music. Please restore the network as soon as possible!", font: .systemFont(ofSize: 18, weight: .medium), textColor: .white, textAlignment: .center, lines: 0)
|
let noticeLabel:UILabel = createLabel("Weak connection. Please check your network", font: .systemFont(ofSize: 18, weight: .medium), textColor: .white, textAlignment: .center, lines: 0)
|
||||||
maskView.addSubview(noticeLabel)
|
maskView.addSubview(noticeLabel)
|
||||||
noticeLabel.snp.makeConstraints { make in
|
noticeLabel.snp.makeConstraints { make in
|
||||||
make.center.equalToSuperview()
|
make.top.equalTo(iconImageView.snp.bottom).offset(20*width)
|
||||||
|
make.centerX.equalToSuperview()
|
||||||
make.width.equalToSuperview().multipliedBy(0.7)
|
make.width.equalToSuperview().multipliedBy(0.7)
|
||||||
}
|
}
|
||||||
return maskView
|
return maskView
|
||||||
@ -143,7 +153,7 @@ class MPPositive_PlayerCoverView: UIView, PKDownloadButtonDelegate {
|
|||||||
maskNotReachableView.snp.makeConstraints { make in
|
maskNotReachableView.snp.makeConstraints { make in
|
||||||
make.left.right.top.bottom.equalTo(coverImageView)
|
make.left.right.top.bottom.equalTo(coverImageView)
|
||||||
}
|
}
|
||||||
maskNotReachableView.isHidden = true
|
maskNotReachableView.isHidden = (MP_NetWorkManager.shared.netWorkStatu == .reachable)
|
||||||
//添加标题
|
//添加标题
|
||||||
addSubview(titleLabel)
|
addSubview(titleLabel)
|
||||||
titleLabel.snp.makeConstraints { make in
|
titleLabel.snp.makeConstraints { make in
|
||||||
@ -232,6 +242,11 @@ class MPPositive_PlayerCoverView: UIView, PKDownloadButtonDelegate {
|
|||||||
}
|
}
|
||||||
//切换当前列表收藏状态
|
//切换当前列表收藏状态
|
||||||
@objc private func collectionSwitchClick(_ sender:UIButton) {
|
@objc private func collectionSwitchClick(_ sender:UIButton) {
|
||||||
|
getUserNotificationCenter()
|
||||||
|
guard MP_NetWorkManager.shared.netWorkStatu == .reachable else {
|
||||||
|
MP_HUD.text("Weak connection.", delay: 2.0, completion: nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
if self.collectionSongBtn.isSelected == true{
|
if self.collectionSongBtn.isSelected == true{
|
||||||
self.collectionSongBtn.isSelected = false
|
self.collectionSongBtn.isSelected = false
|
||||||
if MP_PlayerManager.shared.loadPlayer.currentVideo != nil{
|
if MP_PlayerManager.shared.loadPlayer.currentVideo != nil{
|
||||||
@ -263,6 +278,11 @@ class MPPositive_PlayerCoverView: UIView, PKDownloadButtonDelegate {
|
|||||||
}
|
}
|
||||||
//下载按钮代理
|
//下载按钮代理
|
||||||
func downloadButtonTapped(_ downloadButton: PKDownloadButton!, currentState state: PKDownloadButtonState) {
|
func downloadButtonTapped(_ downloadButton: PKDownloadButton!, currentState state: PKDownloadButtonState) {
|
||||||
|
getUserNotificationCenter()
|
||||||
|
guard MP_NetWorkManager.shared.netWorkStatu == .reachable else {
|
||||||
|
MP_HUD.text("Weak connection.", delay: 2.0, completion: nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
guard MP_PlayerManager.shared.loadPlayer?.currentVideo != nil, MP_PlayerManager.shared.loadPlayer?.currentVideo?.isDlownd == false else {
|
guard MP_PlayerManager.shared.loadPlayer?.currentVideo != nil, MP_PlayerManager.shared.loadPlayer?.currentVideo?.isDlownd == false else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@ -72,7 +72,7 @@ class MPPositive_PlayerListShowTableViewCell: UITableViewCell {
|
|||||||
}
|
}
|
||||||
contentView.addSubview(removeBtn)
|
contentView.addSubview(removeBtn)
|
||||||
removeBtn.snp.makeConstraints { make in
|
removeBtn.snp.makeConstraints { make in
|
||||||
make.width.height.equalTo(24*width)
|
make.width.height.equalTo(44*width)
|
||||||
make.centerY.equalTo(coverImageView.snp.centerY)
|
make.centerY.equalTo(coverImageView.snp.centerY)
|
||||||
make.right.equalToSuperview().offset(-18*width)
|
make.right.equalToSuperview().offset(-18*width)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,7 +29,7 @@ class MPPositive_PlayerSilder: UISlider {
|
|||||||
override init(frame:CGRect) {
|
override init(frame:CGRect) {
|
||||||
super.init(frame: frame)
|
super.init(frame: frame)
|
||||||
setUpLayout()
|
setUpLayout()
|
||||||
print("调整Slider大小")
|
// print("调整Slider大小")
|
||||||
originalFrame = self.frame
|
originalFrame = self.frame
|
||||||
}
|
}
|
||||||
override func awakeFromNib() {
|
override func awakeFromNib() {
|
||||||
|
|||||||
@ -119,6 +119,10 @@ class MPPositive_SearchResultShowTableViewCell: UITableViewCell {
|
|||||||
|
|
||||||
//点击更多
|
//点击更多
|
||||||
@objc private func moreActionClick(_ sender:UIButton) {
|
@objc private func moreActionClick(_ sender:UIButton) {
|
||||||
|
guard MP_NetWorkManager.shared.netWorkStatu == .reachable else {
|
||||||
|
MP_HUD.text("Weak connection.", delay: 2.0, completion: nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
if moreBlock != nil {
|
if moreBlock != nil {
|
||||||
moreBlock!()
|
moreBlock!()
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user