|
|
|
@ -34,7 +34,7 @@ public class MusicService: NSObject { |
|
|
|
private override init() { |
|
|
|
super.init() |
|
|
|
setupRemoteCommandCenter() |
|
|
|
setupAudioSession() |
|
|
|
//setupAudioSession() |
|
|
|
} |
|
|
|
|
|
|
|
public func initialize(serviceUrl: String, userToken: String) { |
|
|
|
@ -44,15 +44,15 @@ public class MusicService: NSObject { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// MARK: - 音频会话设置 |
|
|
|
private func setupAudioSession() { |
|
|
|
do { |
|
|
|
try AVAudioSession.sharedInstance().setCategory(.playback, mode: .default, options: [.allowAirPlay, .allowBluetooth]) |
|
|
|
try AVAudioSession.sharedInstance().setActive(true) |
|
|
|
} catch { |
|
|
|
print("设置音频会话失败: \(error)") |
|
|
|
} |
|
|
|
} |
|
|
|
// // MARK: - 音频会话设置 |
|
|
|
// private func setupAudioSession() { |
|
|
|
// do { |
|
|
|
// try AVAudioSession.sharedInstance().setCategory(.playback, mode: .default, options: [.allowAirPlay, .allowBluetooth]) |
|
|
|
// try AVAudioSession.sharedInstance().setActive(true) |
|
|
|
// } catch { |
|
|
|
// print("设置音频会话失败: \(error)") |
|
|
|
// } |
|
|
|
// } |
|
|
|
|
|
|
|
// MARK: - 基础播放控制 |
|
|
|
func getCurrentUrlString() -> String? { |
|
|
|
|