b面1.0.6蓝牙优化

This commit is contained in:
Mr.zhou 2024-06-13 18:06:54 +08:00
parent 1551807b38
commit 1accd02a50
3 changed files with 55 additions and 52 deletions

View File

@ -1565,7 +1565,7 @@
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1.0.6.1; CURRENT_PROJECT_VERSION = 1.0.6.1;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = T93S37G27F; DEVELOPMENT_TEAM = 8DQD6BV6H9;
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 +1606,7 @@
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1.0.6.1; CURRENT_PROJECT_VERSION = 1.0.6.1;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = T93S37G27F; DEVELOPMENT_TEAM = 8DQD6BV6H9;
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;

View File

@ -22,15 +22,15 @@ class MP_NetWorkManager: NSObject {
private lazy var MPSession:Session = { private lazy var MPSession:Session = {
let configuration = URLSessionConfiguration.af.default let configuration = URLSessionConfiguration.af.default
//4 //4
configuration.timeoutIntervalForRequest = 12 configuration.timeoutIntervalForRequest = 15
configuration.timeoutIntervalForResource = 12 configuration.timeoutIntervalForResource = 15
return Alamofire.Session(configuration: configuration, interceptor: MP_CustomRetrier()) return Alamofire.Session(configuration: configuration, interceptor: MP_CustomRetrier())
}() }()
/// ///
private lazy var PlayerSeesion:Session = { private lazy var PlayerSeesion:Session = {
let configuration = URLSessionConfiguration.af.default let configuration = URLSessionConfiguration.af.default
configuration.timeoutIntervalForRequest = 12 configuration.timeoutIntervalForRequest = 15
configuration.timeoutIntervalForResource = 12 configuration.timeoutIntervalForResource = 15
//4 //4
configuration.httpMaximumConnectionsPerHost = 4 configuration.httpMaximumConnectionsPerHost = 4
return Alamofire.Session(configuration: configuration, interceptor: MP_CustomRetrier()) return Alamofire.Session(configuration: configuration, interceptor: MP_CustomRetrier())
@ -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 {
@ -326,11 +326,24 @@ extension MP_NetWorkManager {
} }
// //
private func requestPostHomeBrowse(_ url:URL, parameters:Parameters) { private func requestPostHomeBrowse(_ url:URL, parameters:Parameters) {
MPSession.request(url, method: .post, parameters: parameters, encoding: JSONEncoding.default).responseData { [weak self] (response) in
guard let self = self else {return}
switch response.result {
case .success(let data):
if let str = String(data: data, encoding: .utf8) {
print(str)
}
case .failure(let error):
break
}
}
//postRootBrowses //postRootBrowses
MPSession.request(url, method: .post, parameters: parameters, encoding: JSONEncoding.default).responseDecodable(of: JsonBrowses.self) { [weak self] (response) in MPSession.request(url, method: .post, parameters: parameters, encoding: JSONEncoding.default).responseDecodable(of: JsonBrowses.self) { [weak self] (response) in
guard let self = self else {return} guard let self = self else {return}
switch response.result { switch response.result {
case .success(let value): case .success(let value):
// print(value)
if value.responseContext?.visitorData != nil { if value.responseContext?.visitorData != nil {
self.visitorData = value.responseContext?.visitorData self.visitorData = value.responseContext?.visitorData
} }
@ -347,6 +360,7 @@ extension MP_NetWorkManager {
browseQueque = nil browseQueque = nil
} }
case .failure(let error): case .failure(let error):
print("Failed to parse browses content")
// //
handleError(url, error: error) handleError(url, error: error)
browseQueque = nil browseQueque = nil

View File

@ -162,7 +162,7 @@ class MP_PlayerManager:NSObject{
// //
NotificationCenter.notificationKey.add(observer: self, selector: #selector(netWorkReachableAction(_ :)), notificationName: .net_switch_reachable) NotificationCenter.notificationKey.add(observer: self, selector: #selector(netWorkReachableAction(_ :)), notificationName: .net_switch_reachable)
// //
NotificationCenter.default.addObserver(self, selector: #selector(handleAudioSessionRouteChangeAction(_ :)), name: AVAudioSession.routeChangeNotification, object: nil) // NotificationCenter.default.addObserver(self, selector: #selector(handleAudioSessionRouteChangeAction(_ :)), name: AVAudioSession.routeChangeNotification, object: nil)
// //
let interval:CMTime = .init(seconds: 1, preferredTimescale: .init(1)) let interval:CMTime = .init(seconds: 1, preferredTimescale: .init(1))
//线 //线
@ -281,29 +281,29 @@ class MP_PlayerManager:NSObject{
} }
} }
/// ///
@objc private func handleAudioSessionRouteChangeAction(_ notification: Notification) { // @objc private func handleAudioSessionRouteChangeAction(_ notification: Notification) {
guard let info = notification.userInfo, let reasonValue = info[AVAudioSessionRouteChangeReasonKey] as? UInt, let reason = AVAudioSession.RouteChangeReason(rawValue:reasonValue) else { // guard let info = notification.userInfo, let reasonValue = info[AVAudioSessionRouteChangeReasonKey] as? UInt, let reason = AVAudioSession.RouteChangeReason(rawValue:reasonValue) else {
return // return
} // }
switch reason { // switch reason {
case .newDeviceAvailable:// // case .newDeviceAvailable://
let session = AVAudioSession.sharedInstance() // let session = AVAudioSession.sharedInstance()
for output in session.currentRoute.outputs where output.portType == .headphones { // for output in session.currentRoute.outputs where output.portType == .headphones {
print("耳机已连接") // print("")
} // }
// // //
case .oldDeviceUnavailable:// // case .oldDeviceUnavailable://
if let previousRoute = info[AVAudioSessionRouteChangePreviousRouteKey] as? AVAudioSessionRouteDescription { // if let previousRoute = info[AVAudioSessionRouteChangePreviousRouteKey] as? AVAudioSessionRouteDescription {
for output in previousRoute.outputs where output.portType == .headphones { // for output in previousRoute.outputs where output.portType == .headphones {
print("耳机已断开") // print("")
} // }
} // }
// // //
pause() // pause()
default: // default:
break // break
} // }
} // }
//KVO //KVO
override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) { override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
@ -743,17 +743,6 @@ class MP_PlayerManager:NSObject{
} }
} }
} }
//
// private func updateProgress(_ time:TimeInterval) {
// guard var currentInfo = currentInfo else {
// return
// }
// currentInfo[MPNowPlayingInfoPropertyElapsedPlaybackTime] = setTimesToMinSeconds(time)
// DispatchQueue.main.async {
// print(currentInfo)
// //
// MPNowPlayingInfoCenter.default().nowPlayingInfo = currentInfo
// }
// }
} }