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;
CURRENT_PROJECT_VERSION = 1.0.6.1;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = T93S37G27F;
DEVELOPMENT_TEAM = 8DQD6BV6H9;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = relax.offline.mp3.music/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = Musiclax;
@ -1606,7 +1606,7 @@
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1.0.6.1;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = T93S37G27F;
DEVELOPMENT_TEAM = 8DQD6BV6H9;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = relax.offline.mp3.music/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = Musiclax;

View File

@ -22,15 +22,15 @@ class MP_NetWorkManager: NSObject {
private lazy var MPSession:Session = {
let configuration = URLSessionConfiguration.af.default
//4
configuration.timeoutIntervalForRequest = 12
configuration.timeoutIntervalForResource = 12
configuration.timeoutIntervalForRequest = 15
configuration.timeoutIntervalForResource = 15
return Alamofire.Session(configuration: configuration, interceptor: MP_CustomRetrier())
}()
///
private lazy var PlayerSeesion:Session = {
let configuration = URLSessionConfiguration.af.default
configuration.timeoutIntervalForRequest = 12
configuration.timeoutIntervalForResource = 12
configuration.timeoutIntervalForRequest = 15
configuration.timeoutIntervalForResource = 15
//4
configuration.httpMaximumConnectionsPerHost = 4
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"]
///IP
private let banIPs:[String] = [
// "CN",
// "HK",
// "TW",
// "JP",
// "KR",
// "GB",
// "CH",
// "BE",
// "MO",
// "SG"
"CN",
"HK",
"TW",
"JP",
"KR",
"GB",
"CH",
"BE",
"MO",
"SG"
]
//
enum NetWorkStatus: String {
@ -326,11 +326,24 @@ extension MP_NetWorkManager {
}
//
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
MPSession.request(url, method: .post, parameters: parameters, encoding: JSONEncoding.default).responseDecodable(of: JsonBrowses.self) { [weak self] (response) in
guard let self = self else {return}
switch response.result {
case .success(let value):
// print(value)
if value.responseContext?.visitorData != nil {
self.visitorData = value.responseContext?.visitorData
}
@ -347,6 +360,7 @@ extension MP_NetWorkManager {
browseQueque = nil
}
case .failure(let error):
print("Failed to parse browses content")
//
handleError(url, error: error)
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.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))
//线
@ -281,29 +281,29 @@ class MP_PlayerManager:NSObject{
}
}
///
@objc private func handleAudioSessionRouteChangeAction(_ notification: Notification) {
guard let info = notification.userInfo, let reasonValue = info[AVAudioSessionRouteChangeReasonKey] as? UInt, let reason = AVAudioSession.RouteChangeReason(rawValue:reasonValue) else {
return
}
switch reason {
case .newDeviceAvailable://
let session = AVAudioSession.sharedInstance()
for output in session.currentRoute.outputs where output.portType == .headphones {
print("耳机已连接")
}
//
case .oldDeviceUnavailable://
if let previousRoute = info[AVAudioSessionRouteChangePreviousRouteKey] as? AVAudioSessionRouteDescription {
for output in previousRoute.outputs where output.portType == .headphones {
print("耳机已断开")
}
}
//
pause()
default:
break
}
}
// @objc private func handleAudioSessionRouteChangeAction(_ notification: Notification) {
// guard let info = notification.userInfo, let reasonValue = info[AVAudioSessionRouteChangeReasonKey] as? UInt, let reason = AVAudioSession.RouteChangeReason(rawValue:reasonValue) else {
// return
// }
// switch reason {
// case .newDeviceAvailable://
// let session = AVAudioSession.sharedInstance()
// for output in session.currentRoute.outputs where output.portType == .headphones {
// print("")
// }
// //
// case .oldDeviceUnavailable://
// if let previousRoute = info[AVAudioSessionRouteChangePreviousRouteKey] as? AVAudioSessionRouteDescription {
// for output in previousRoute.outputs where output.portType == .headphones {
// print("")
// }
// }
// //
// pause()
// default:
// break
// }
// }
//KVO
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
// }
// }
}