b面1.0.6蓝牙优化
This commit is contained in:
parent
1551807b38
commit
1accd02a50
@ -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;
|
||||
|
||||
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
//发送post请求,并将结果转为RootBrowses
|
||||
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
|
||||
|
||||
@ -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
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user